set canonical url category pages page/2/ page/3/

#44640
  • Resolved frednl
    Rank Math free

    Hi i want set canonical url for category paginations. For exaple: i have a cagetory and name of this category: City

    sitename.com/city/page/2 – sitename.com/city/page/3 for like this pages i need canonical url : sitename.com/city/

    yes category edit page i can doing this but i have 1K+ categories i need automaticly do that.

    Thank you.

    • This topic was modified 4 years, 7 months ago by frednl.
    • This topic was modified 4 years, 7 months ago by frednl.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello,

    Thank you for contacting Rank Math today.

    You can use the following filter to change the canonical url:

    /**
     * Allow changing of the canonical URL.
     *
     * @param string $canonical The canonical URL.
     */
    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	return $canonical;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    frednl
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    frednl
    Rank Math free

    Hi sory but not work for me.

    for example yoast seo i was using this code:

    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');

    So i want only one URL for caninoal url on category url’s page/2/ page/3/… category link.

    sitename.com/city/page/2/ in this page caninoal url must be: “sitename.com/city”

    • This reply was modified 4 years, 7 months ago by frednl.
    • This reply was modified 4 years, 7 months ago by frednl.
    Todd
    Rank Math free

    Hi Firat,

    That is not the recommended way of doing things. The canonical on paginated series must be the current page in the series. Otherwise, you might as well noindex your paginated series (that option is provided by the way).

    http://www.thesempost.com/google-recommends-self-referencing-canonicals/

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    frednl
    Rank Math free

    thank you for explain, i dont want my pagination index.. for category pages and sitename.com/page/2 sitename.com/page/3/ what i should do?

    because im using static page at home, i dont have pagination homepage. And i want give power my category (default url: sitename/category/city like this)

    what you recommended for this? thank you…

    Todd
    Rank Math free

    Hi,

    I would recommend going to WordPress Dashboard > Rank Math > Titles & Meta > Misc Pages
    null

    Enable the Noindex Paginated Pages option.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hi Team,
    How do I set self canonicals on paginated pages using the same code on functions.php?
    Current Scenario:
    /page/2 – canonical to main page

    Expected Scenario:
    /page/2 having self canonical

    Todd
    Rank Math free

    Hi Suhas,

    You can use this filter to change canonical URLs per your preference:
    https://rankmath.com/kb/filters-hooks-api-developer/#change-canonical-url

    Please note that we do not offer support for customizations that are not part of the plugin. If you are note familiar with coding, you can consult a coder to customize the filter for your situation. Do note that we neither support this type of edit and neither do we recommend doing this having provided the reason above already.

    If you need help with anything else, please open a new support ticket here so we can help.

    We are always here for assistance.

Viewing 8 replies - 1 through 8 (of 8 total)

The ticket ‘set canonical url category pages page/2/ page/3/’ is closed to new replies.