PHP, Template Tags, WP/CP | Type: PHPDisplay the Title for the Posts / Blog Page

You can’t use the standard the_title(); template tag for the page name of the page that displays the blog listing (index.php); that tag will display the latest blog post title rather than the page title.

Instead, use this:

<?php
if(is_archive()) {
    echo '<h1>Blog Posts';
        if(is_category()) {
            echo ': ';
            echo single_cat_title();
        } elseif(is_tag()) {
            echo ': ';
            echo single_tag_title();
        } else {
            echo ': ';
            echo single_month_title(' ', true);
        }
    echo '</h1>';
} else {
    echo '<h1>Blog</h1>';
}
?>

We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept