Noindex for comment pagination

  • Hello,

    How does Rank Math handle comment pagination?
    I have paginated reviews for my Woocommerce store.
    Now I have producturl/comment-page-1 , producturl/comment-page-2 etc .

    These links are similar in content so i would like to noindex them.
    The only option that might address this issue is in Rank Math-> Titles & Meta -> Misc Pages -> Noindex Paginated Pages.

    However, according to the description, this also sets archive pages to Noindex.
    Is there a way to Noindex only the comment pages?

    Thank you.

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math today.

    You can use the following code snippet to set the paginated pages to noindex:

    /**
     * Allows filtering of the robots meta data.
     *
     * @param array $robots The meta robots directives.
     */
    add_filter( 'rank_math/frontend/robots', function( $robots ) {
        if ( ! empty( get_query_var( 'cpage' ) ) ) {
           $robots['index'] = 'noindex';
           $robots['follow'] = 'nofollow';
        }
    	return $robots;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

    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 ‘Noindex for comment pagination’ is closed to new replies.