Pagination/canonical

#232241
  • Resolved Vladimir Lalovic
    Rank Math free

    Hi,

    I have categories/subcategories on my website and I need to set up pagination and canonicals as follows…

    Paginated pages on categories:
    Url: domain.com/category/page/2 3…etc. – noindex/follow

    Canonical:
    all paginated pages to point to main category – domain.com/category/

    Paginated pages on sub-categories:
    Url: domain.com/category/sub-categorypage/2 3…etc. – noindex/nofollow

    Canonical:
    all paginated pages to point to main sub-category – domain.com/category/sub-category/

    I know all about the google recommendations regarding pagination but I need to implement this and I’m interested if there is a way to implement through your plugin,

    Thanks

Viewing 1 replies (of 1 total)
  • Hello,

    Thanks for contacting us. Sorry for the delay and any inconvenience that might have been caused due to that.

    I have already provided the filter given below in the response to your previous ticket regarding the same issue: https://support.rankmath.com/ticket/paginated-pages-canonical/?view=all#post-220017

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

    Please copy this code and paste it into your theme’s functions.php file and this will set the canonical of your paginated pages as the main page.

    Hope this helps. Let us know if you need any further assistance.

    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 ‘Pagination/canonical’ is closed to new replies.