• Resolved manav kalra

    (@manavkalra15)


    Hello,

    I have removed pagination from my website’s homepage, I want to add noindex,follow to homepage pagination pages. Please provide me php code to do that.

    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @manavkalra15,

    Thank you for contacting the support.

    If you’ve removed the pagination, the homepage would not return true of the is_paged() function. In this case, you’ll need to apply the desired robots meta settings based on the URL.

    Depending upon how the URL structure for pagination was set on your website, you might need to slightly modify the below filter to get the desired output:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
    if(strpos($_SERVER["REQUEST_URI"], '/page/')) {
    $robots["index"] = 'noindex';
    $robots["follow"] = 'follow';
    }
    return $robots;
    });

    In the above code, you’ll need to replace /page/ with the prefix of the paginated URL of the homepage.

    Here’s how you can add the filter to the website: https://rankmath.com/kb/filters-hooks-api-developer/

    Let us know how that goes.

Viewing 1 replies (of 1 total)
  • The topic ‘How to add nofollow, index to pagination on homepage’ is closed to new replies.