Canonicals and titles pagination problem

#68051
  • Resolved Michele Girardi
    Rank Math pro

    The %page% tag does not work on my site homepage.
    I use the Sahifa theme and a static page on the homepage. I would like to change the titles of the pagination (i.e.: mysite.com/article/page/2) pages by inserting %page% tag in the meta title snippet and setting the canonical to the main url, but I can’t do it

Viewing 3 replies - 1 through 3 (of 3 total)
  • Alberto
    Rank Math business

    Hello,

    Rank Math %page% variables only work on the archive pages. Since your homepage is a static page, the variable is not working. To make it work, I added the following code in your themeā€™s functions.php file:

    add_filter( 'rank_math/frontend/title', function( $title ) {
    	if ( ! is_front_page() ) {
    		return $title;
    	}
    
    	global $wp_query;
    	if ( ! empty( $wp_query->query[ 'paged' ] ) && $wp_query->query[ 'paged' ] > 1 ) {
    		return $title . ' ' . $wp_query->query[ 'paged' ];
    	}
    	return $title;
    });

    The paginated page title is now showing the page number with the main title. Can you please confirm?

    Thank you.

    thank you so much! tomorrow I will check and let you know!

    Alberto
    Rank Math business

    Hello,

    Perfect, I hope it works for you but if not we will be here to continue helping you with this.

    Looking forward to help 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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Canonicals and titles pagination problem’ is closed to new replies.