How to give self referencing canonical tag to paginated pages

#399527
  • Resolved theecommtask
    Rank Math free

    Hello,
    I am trying to add self canonical tags to our faceted canonical pages.
    Currently I am using filter everything plugin which gives canonical tag to paginated pages as the first page

    add_filter( 'rank_math/frontend/canonical', function( $canonical ) {
    	$current_url="https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    	if(false === strpos($current_url, '/page/')) return $canonical;
    	$canonical = strtok($current_url, '?');
    	return $canonical;
    });
    

    I am using this code. But it didn’t work.

Viewing 1 replies (of 1 total)
  • Prabhat
    Rank Math agency

    Hello,

    Thank you for contacting the support and we regret the inconvenience caused.

    I checked the source of the page and the canonical tag seems to have been generated by the Filter Everything plugin.

    The filter you’re trying to use is correct but would only work for the canonical tag generated by Rank Math.

    If you wish to use the canonical tags of Rank Math, please disable that plugin or disable its SEO-related features and see if that helps.

    Let us know how that goes.

    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 ‘How to give self referencing canonical tag to paginated pages’ is closed to new replies.