Adding page title to blog page - Twenty Ten theme (4 posts)

  1. alexcreedy
    Posted 4 years ago #


    I have a blog page on a website (its not the homepage)


    I want to add a main heading before the first Post that just says 'Blog'. I have tried adding code directly to a new page template as I have done this page which has custom posts :

    Also tried adding code to the 'Blog' page in the dashboard but no luck yet.


  2. annapootle
    Posted 4 years ago #

    Does the page display a title by default?

    If not, try going to the Blog page in Dashboard and adding:
    before any other content.
    But, you may need to go into the template for blog page and edit php.
    Hope this helps!

  3. The_liz
    Posted 4 years ago #

    Sorry, adding it to the page content simply doesn't work. Here is a moderately quick and dirty method (you are using a child theme, right?):
    -Go to your parent theme and get index.php
    -Right after <?php if ( have_posts() ) : ?> add <h1 class="entry-title">Blog</h1>
    -Save file in your child theme as "home.php"

    If anyone has code for grabbing the blog page title off the page rather than hardcoding it, that'd be cool too.

  4. Michael
    Forum Moderator
    Posted 4 years ago #

    not sure if this is the most elegant way, but it works to output the blog page (posts page) title when a static front page is set:

    if( is_home() && get_option('page_for_posts') ) {
    	$blog_page_id = get_option('page_for_posts');
    	echo '<h1>'.get_page($blog_page_id)->post_title.'</h1>';

Topic Closed

This topic has been closed to new replies.

About this Topic