How disable canonical and index from categories with sorting

#657469
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Apologies for the delay as we currently have a high volume of tickets here in our support forums.

    Yes, you can use and customize this filter to set those URLs to noindex:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    $url = home_url( $_SERVER['REQUEST_URI'] );
    if( (strpos($url,'?orderby=') !== false) ) {
    $robots["index"] = 'noindex';
    $robots["follow"] = 'nofollow';
    }
    return $robots;
    });

    You can add the filter to your theme’s functions.php file or you can follow any of the methods mentioned in the guide below to add this filter to your website:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    If there are more parameter/filtered queries like ?orderby=, you can share them here so we can also adjust the filter.

    Hope that helps.

    Thank you.

    Anonymous
    Rank Math free

    Great, thank you!

    And guesing that to change/disable canonical link above I can use:

    add_filter( ‘rank_math/frontend/canonical’, function( $canonical ) {
    return $canonical;
    });

    Anonymous
    Rank Math free

    Ok, I saw that when I changed to nofollow, canonical link disapear – thank you!

    Hello,

    Glad that everything has been sorted out.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

The ticket ‘How disable canonical and index from categories with sorting’ is closed to new replies.