page_title_metatag
Filter the page title tag.
You need to have a working knowledge of Hooks before you get started.
Parameters
| Name | Type | Description |
|---|---|---|
$value |
parameter |
(string) |
$params |
parameter |
(array) associative array with contextual data |
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
Clickfwd\Hook\Filter::add('page_title_metatag', function($value, $params)
{
// Uncomment line below to view available data passed into hook
// fwd_dd($value, $params);
return $value;
});
Examples
Prepend Listing Count To Category Page Title Tag
This example will prepend the total number of listings in a category page to the page title tag.
function add_count_to_category_title($title, $params)
{
$categoryPage = S2Array::get($params,'route') == 'categories.category';
$catId = S2Array::get($params,'vars.cat_id');
$menuId = S2Array::get($params,'vars.params.Itemid');
$count = S2Array::get($params,'pagination.total');
if ( $categoryPage && $count )
{
$title = $count .' '.$title;
}
return $title;
}
Clickfwd\Hook\Filter::add('page_title_metatag', 'add_count_to_category_title', 10);
Source Files
/services/metatags/metatags.php/cms_compat/wordpress/plugins/yoast_compat_lists.php/cms_compat/wordpress/includes/plugins/jreviews.php/cms_compat/joomla/includes/plugins/jreviews.php/cms_compat/joomla/includes/plugins/jreviews-joomla4.php