page_description_metatag
Filter the description meta 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_description_metatag', function($value, $params)
{
// Uncomment line below to view available data passed into hook
// fwd_dd($value, $params);
return $value;
});
Examples
Only use custom meta description for featured listings
If you sell paid listings, you could include as part your paid plans having a customized meta description tag to make the listings more discoverable for SEO. This simple example shows how to approach this.
Clickfwd\Hook\Filter::add('page_description_metatag', function($value, $params)
{
$listing = $params['listing'] ?? null;
// Only continue if it's a listing detail page
if (! $listing) {
return $value;
}
// Only continue if listing is in a paid category
if (empty($listing['Paid'])) {
return $value;
}
// Only continue if it's a featured listing
if (! $listing['Listing']['featured']) {
return "Generic meta description for listing {$listing['Listing']['title']}";
}
// Featured listings show the custom meta description or if empty the listing summary
return $listing['Listing']['metadesc'] ?: substr($listing['Listing']['summary'], 0, 150).'...';
}
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