Change AMP WordPress Title Tags add Name Mobile Version

Thursday, 03 Jun 2021 15:51:58 WIBby
English

CILACAP.INFO – We check search engine optimization (SEO) tools on Semrush, but we found issue on meta title.

On Semrush detect duplicate title tags from non AMP and AMP (Accelerated Mobile Pages), because problem this, then we are trying to fix it.

We think that most appropriate solution to prevent duplicate meta title tags in WordPress is to add an attribute in the AMP page with the name “Mobile Version”.

The method is not so difficult, you can use add_filter with the document_title_parts attribute on functions.php.

Then don’t forget to add if (function_exists( ‘is_amp_endpoint’ ) && is_amp_endpoint()) { // do stuff } so that the name “Mobile Version” is only found on AMP pages.

If the theme you are using supports amp, then you can use if(nametheme_is_amp()).

Okay this code can you use and add on fuctions.php in your theme.

add_filter( ‘document_title_parts’, function( $title ) {
if ( mytheme_is_amp() )
$title[‘amp’] = ‘Mobile Version’;
return $title;
} );

Don’t forget, change mytheme_is_amp with your theme if your theme support amp paired with plugins AMP.

Comment