open
24.08.2022.

Duplicate meta description solution – code or wordpress plugin

Last update: 16.09.2022.

Some plugins provide a search engine optimized page description, but many wordpress themes already have a default one.

This plugin or code snippet solves this problem by deleting the FIRST meta description from the header code.

<?php function twd_remove_first_meta_description($html) {
$pattern = '/<meta name(.*)=(.*)”description”(.*)>/i';
$html = preg_replace($pattern, ”, $html,1);
return $html;
}
function twd_clean_meta_description($html) {
ob_start('twd_remove_first_meta_description');
}

add_filter('get_header', 'twd_clean_meta_description', 1);
?>

Copy to Clipboard

Related posts

Got a question? Is something not working? Write and I'll answer!

Leave a Reply

Your email address will not be published.

1 × 3 =