• Resolved jacky_K

    (@jacky_k)


    Hello. After update 14, the filter for canonical stopped working. Example:

    function return_canon () {
    $canon_page = get_pagenum_link(1);
    return $canon_page;
    }
    function canon_paged() {
    if (is_paged()) {
    add_filter( 'wpseo_canonical', 'return_canon' );
    }
    }
    add_filter('wpseo_head','canon_paged');

    How to fix it?

    • This topic was modified 4 years, 10 months ago by jacky_K.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @jacky_k,

    Sorry for the trouble.

    Just to confirm, can you please post here some examples on how your canonical URL output it was earlier and what’s the new change you’ve seen after v14.xx update?

    Can you illustrate them with an example, so we can try reproducing the issue and give you the possible fix?

    Thank you.

    Thread Starter jacky_K

    (@jacky_k)

    I used the filter on category pagination pages.
    For example, for pages:
    site.com/category/wordpress/page/2/
    site.com/category/wordpress/page/3/
    site.com/category/wordpress/page/4/
    The filter changed the canonical address to the address of the first page:
    <link rel="canonical" href="https://site.com/category/wordpress/" />

    After update 14, I see in the source code of the page:
    <link rel="canonical" href="https://site.com/category/wordpress/page/2/" />
    <link rel="canonical" href="https://site.com/category/wordpress/page/3/" />
    <link rel="canonical" href="https://site.com/category/wordpress/page/4/" />`

    This is very very very bad for SEO.

    • This reply was modified 4 years, 10 months ago by jacky_K.
    • This reply was modified 4 years, 10 months ago by jacky_K.
    • This reply was modified 4 years, 10 months ago by jacky_K.
    Plugin Support marcanor

    (@marcanor)

    Hi @jacky_k,

    The reason why the Yoast SEO plugin adds a self-referencing canonical to each page in the archive is that, When you canonicalize the paginated archive pages to the first page of the archive, search engines will stop indexing the links on the archive pages.
    This could cause older articles to drop out of the search results entirely.

    You can find more information here.

    That being said, we changed the last line of your code from:
    add_filter(‘wpseo_head’,’canon_paged’); to
    add_filter(‘wpseo_canonical’,’canon_paged’);
    and it seems to work.

    Thread Starter jacky_K

    (@jacky_k)

    Thanks for the answer.
    1. Your code does not change the canonical. He removes it. This is different.
    2. You are linking to an outdated article. Google hasn’t supported rel=next/prev since Mar 21, 2019 https://searchengineland.com/google-no-longer-supports-relnext-prev-314319
    I’m sorry that the developers of the plugin for SEO do not know the latest changes in Google.

    Plugin Support marcanor

    (@marcanor)

    Hi @jacky_k ,

    Thanks for getting back to us.

    1) You are correct, we checked the wrong settings during our testing, sorry for that.
    Yoast SEO 14.0 introduces new Presenters to allow you to make change to the meta data.
    You can find more information here. You can find additional information with an example to change OpenGraph tags here.

    2) We are aware of the changes Google has made with regards to rel=next/prev. We have an article with more information here here. However, our recommendation from the article linked in the reply above remains the same: have self-referencing canonical links on paginated pages. You can find more information here.

    Please let us know if you have any further questions.

    • This reply was modified 4 years, 9 months ago by marcanor.

    Hi @jacky_k ,

    We’re closing this thread because we haven’t heard back from you in a while. Should you have further questions, please open a new thread.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Filter for canonical’ is closed to new replies.