Page Number in Archive Headings
Adds "Page 2 of 7" to archive headings on paginated pages, so visitors and search engines can tell the pages apart.
Opens WPIDE on
Code
add_filter( 'get_the_archive_title', function ( $title ) {
global $wp_query;
$paged = (int) get_query_var( 'paged' );
if ( $paged > 1 ) {
$title .= sprintf( ' <span class="wpide-archive-page">– Page %1$d of %2$d</span>', $paged, max( $paged, (int) $wp_query->max_num_pages ) );
}
return $title;
}, 30 );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.