Created
February 27, 2025 09:12
-
-
Save rilwis/b755b19c4b345b396d4e55775e4b3f76 to your computer and use it in GitHub Desktop.
Slim SEO: Add total page number to the meta title for paginated pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'slim_seo_data', 'change_pagination_text' ); | |
add_filter( 'document_title_parts', 'change_pagination_text' ); | |
function change_pagination_text( $data ) { | |
if ( ! is_paged() ) { | |
return $data; | |
} | |
global $wp_query; | |
$paged = get_query_var( 'paged' ); | |
$data['page'] = 'Page ' . $paged . ' of ' . $wp_query->max_num_pages; | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment