Wordpress category pages URL

#937268
  • Resolved Sâlih Bora
    Rank Math free

    Hello.
    Wordpress adds something like /?cat=-1 to the end of the URL of category pages or to the home page to indicate which page the category is on.
    I want to tag these pages with noindex.
    How can I?
    Thank you.

Viewing 1 replies (of 1 total)
  • Hello,

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

    You can add this filter on your site to set those URLs to noindex:

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

    If you’re not sure how to add this code, you can follow this guide:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Wordpress category pages URL’ is closed to new replies.