Add filter on wp_title not working with Yoast SEO plugin

For SEO purposes, in a specific template that has a list of items with pagination, I need to have different…

February 22, 2017

For SEO purposes, in a specific template that has a list of items with pagination, I need to have different urls and titles. Urls change using .../page/2/, .../page/3/ and the paging is handled with get_query_var('paged'). But Yoast SEO plugin doesn’t add automatically the number to the title so in the Google Search Console these pages are considered duplicates.
This code in the functions.php fixes the problem, the number “50” in the add_filter call refers to the priority, so this filter runs after the Yoast’s one and do the work!

function modify_title_with_pagination( $title ) {
	if(get_query_var('paged') && get_query_var('paged') > 0) {
		if ( is_page_template( 'your-template.php' )) {
			return $title . " (page ".get_query_var('paged').")";
    return $title;
add_filter( 'wp_title', 'modify_title_with_pagination', 50,2 );


I'm a software engineer, an everyday web developer and a maker. I usually build sites with PHP, within or without WordPress. I build Internet of Things with Arduino and ESP8266. I'm the founder of and and I'm actually the Chief Technical Officer of Better Days web agency.


Clean up and optimize WordPress head tag

If you need to know how to remove RSS Feed URL’s from page head or how to remove post relational…

December 11, 2015

Stop sending email to new user in WordPress admin registration

Prevent WordPress to send notification emails when you manually create new users

March 9, 2017

Generate all old PDF preview images with WordPress 4.7

WordPress 4.7 generates thumbnails for PDF files while uploading them in the media library, this is a really good thing…

December 13, 2016

How to add rel=”nofollow” to links with preg_replace()

Adding rel="nofollow" to external link is a good SEO practice.

September 22, 2015

WordPress 4.1.1 is available! Please update now.

Sometimes you find messages like “WordPress 4.1.1 is available! Please update now.“, in italian it is: “È disponibile WordPress 4.1.1! Aggiorna…

March 16, 2015

A new avatar generator for WordPress with get_avatar and Flathash

Brand new avatars for WordPress Gravatar service

April 7, 2017