Skip to content

Add Current Page Number to the Page Title

In this article

    This snippet adds the current page number to the page header title on paginated archives such as the blog, categories, tags and search results, for example “Blog – Page 2 of 5”.

    It isn’t built into the theme because it can make titles look clunky, and WordPress and SEO plugins already add the page number to the browser title tag, which is what search engines use.

    /**
     * Display the current page number next to the page title.
     */
    add_filter( 'wpex_title', function( $title ) {
    	if ( $title && is_paged() && ! is_singular() ) {
    		$title .= ' - {{paged}}';
    	}
    	return $title;
    }, 20 );
    All PHP snippets should be added via child theme's functions.php file or via a plugin.
    We recommend Code Snippets (100% Free) or WPCode (sponsored)
    Related Snippets
    Back To Top