How to set a custom title for Posts page in WordPress

Posted on
5/5 - (331 votes)

When a static Page (typically titled Blog) is set as the Posts page at Settings > Reading in WordPress, its title will usually appear at example.com/blog.

The easiest way to set what appears as the Posts page’s title is to change it in the backend.

But for some reason, if you want the frontend title text to be different to the backend title, the_title filter hook is your friend.

Adding the following to the active theme’s functions.php will make “Latest News” text appear as the Posts page title on the Posts page:

add_filter( 'the_title', 'custom_posts_page_title', 10, 2 );
/**
 * Sets custom title for the Posts page.
 *
 * @param  string $title Current title.
 * @param  int $id The post ID.
 *
 * @return string Modified title.
 */
function custom_posts_page_title( $title, $id ) {
    // get the id of Posts page.
    $posts_page = get_option( 'page_for_posts' );

    // if we are not on an inner Posts page, abort.
    if ( ! is_home() || is_front_page() ) {
        return $title;
    }

    // if the current entry's ID matches with that of the Posts page..
    if ( $id == $posts_page ) {
        // set your new title here.
        $title = 'Latest News';
    }

    return $title;
}