Ad

Wordpress Posts Page Canonical

- 1 answer

Hi at the moment I have an issue with the canonicals of the posts page.

each post page got a wrong canonical

for example I haf this page:

http://www.blog.de/page/2

canonical is: http://www.blog.de/page/2 canonical should be: http://www.blog.de/

how can I change this?

Thanks in advance

Ad

Answer

I think you are using some plugin, which generates a canonical URL. Most probably Yoast SEO plugin. If Yoast SEO plugin, you can use this filter:

add_filter('wpseo_canonical' , 'change_canonical', 10,1):

function change_canonical($url){
   if(is_home()) { // Checking if Blog listing page
     $url = 'http://www.blog.de/'; 
    } else if(is_page('other')) { // you can check any page, single or any condition you want
      $url = 'http://www.blog.de/other-page'
    }
  return $url;
} 

Let me know if it works or you are using different plugin. Hope it will help.

Ad
source: stackoverflow.com
Ad