Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2341

Joomla! 5.x Coding • Re: Behavior-Backward Compatibility plugin unchecked: issue with the Canonical URL SEO

$
0
0
Use the method FieldsHelper::getFields() to access the custom fields.

Code:

// add this use statement after use statements in the beginning:// use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;$customFields = FieldsHelper::getFields('com_content.article', $this->item, true);$values = array_column($customFields, 'value', 'name');if ($values['canonical-url'] !== '') {$canonicalLink = '<link rel="canonical" href="' . $values['canonical-url'] . '" />';$document = Factory::getDocument();$document->addCustomTag($canonicalLink);}

Statistics: Posted by toivo — Mon Apr 08, 2024 11:42 pm



Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>