Wordpress category pages URL

#937268
  • 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.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.