Pagination

#930420
  • I’m working on a news website portal and I want to make the following set up of the Category and Subcategory pages:

    Category page no 1: index,follow,self-referencing canonical
    Category page 2+: noindex,follow, canonical to the category page no 1
    Subcategory page no 1: index,follow,self-referencing canonical
    Subcategory page 2+: noindex,nofollow, canonical to the subcategory page no 1
    Tag page no 1: index,follow,self-referencing canonical
    Tag page no 2+: noindex,nofollow, canonical to tag page no 1

    The website has 8 Categories and approximately 50 Subcategories. Some categories have more than 4000 paginated pages.
    Is it possible to make the above settings automatically with Rank Math PRO, and if it is possible, how to make it?

    Best regards

    Slaven

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

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

    Please note that the canonical URL is only required if the pages are going to be indexed on Google. Since you want to add the noindex and nofollow attributes to these pages, there is no need to add any canonical URL.

    Rank Math also only includes the canonical URL to the pages that are set to index.

    However, you can set the paginated pages to Noidex from WP Dashboard > Rank Math > Titles & Meta > Miscellaneous Pages:

    In case, you want to use both Noindex and nofollow attributes, you can use the following filter code on your website:

    add_filter( 'rank_math/frontend/robots', function( $robots ) {
        
        if ( (is_category() || is_tag()) && is_paged() ) {
            $robots['index'] = 'noindex';
            $robots['follow'] = 'nofollow';
        }
        
        return $robots;
    });
    

    Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how it goes. Looking forward to helping you.

    Hi

    Thank you for the answer.
    Please note I will not add canonical to pages which will be at noindex.
    I need paginated pages to be canonicalized to page no 1, which is indexed.
    Is that possible to make in bulk with RankMath Pro?
    I have to many pages to go one by one manually

    Best regards

    Slaven

    Hello,

    There’s no option in Rank Math PRO to set the canonical of your pagination to the first page.

    However, to set the canonical to the first page, you can use this filter on your site:

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	if ( is_paged() ) {
    			$link = $_SERVER['REQUEST_URI'];
    			$arr = explode('/page/', $link,);
    			$canonical = home_url($arr[0]. '/');
    		}
    		return $canonical;
    });

    And here’s a guide to adding the code to the website:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps.

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

You must be logged in to reply to this ticket.