• Resolved Dr_jAcKaSS

    (@dr_jackass)


    Hi!

    I have set Front page as a static page (“Home”) and posts page to page “News”.

    It works, but there is no News title on top of “News” page (that shows posts). What do I need to do that a page title on posts page will be displayed?

Viewing 6 replies - 1 through 6 (of 6 total)
  • I think you’d need to pretty much hardcode it in your theme’s index.php file:

    <?php if( is_home() ) :?>
    <h1>News</h1>
    <?php endif;?>
    Thread Starter Dr_jAcKaSS

    (@dr_jackass)

    But “News” page is not home page. “Home” is home page, “News” is just one of several pages.

    <?php if( is_page('news') ) :?>
    <h1>News</h1>
    <?php endif;?>

    Change ‘news’ to the actual page-name or page ID.

    This would go in the template assigned to the page, or page.php, or index.php if you don’t have either of these.

    Although I agree with esmi solution, if the news page is set as the posts page, it should respond to is_home()..

    Thread Starter Dr_jAcKaSS

    (@dr_jackass)

    hm…

    Is there any way to get the page title from database? Because I use qtranslate (ok, I can hardcode this aswell), but anyway it were nicer if I could use something like <h2><?php the_title(); ?></h2>.

    I’m not too sure what you mean here, the_title() does get the title from the database! Or you can use get_the_title(id);

    Thread Starter Dr_jAcKaSS

    (@dr_jackass)

    Thanks xdesi! I have figured it out!

    I did a bit of investigation which temlate file is used for pages, which for blog.

    So in my case index.php is used for blog. So I have added <h2><?php echo get_the_title($page_id) ?></h2>. So now it is completely flexible. If I assign blog to any page it works correctly.

    Otherwise, the_title() returns the title of the post (if used in blog template file), not the page title. So if you use it outside of the loop, you just get the first post title.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Page title not showing on posts page’ is closed to new replies.