1

Background

I have created a Page called Blog. I have selected "A Static Page" > Post Page > Blog In the "home.php" I am displaying all post with while(have_post()) This is working fine. It is displaying all post.

The issue I am having is when I return the page title with <?php the_title(); ?> is returns the most recent post's title which is "Post 6" instead of "Blog" the name of the page.

I am also displaying the content of the "blog" page as well but again it is displaying the content of the most recent post.

So how do I display the page content of the page blog?

<?php get_header(); ?>

<?php the_title(); ?> 
<div class="row">
<div class="large-9 columns">
<?php if ( have_posts() )  { ?>
    <div class="row">
        <?php 
            while ( have_posts() ) {
            the_post();
        ?>
        <div class="large-12"> 
                <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
                <?php if ( has_post_thumbnail() ) { ?>
                    <?php echo get_the_post_thumbnail(); ?>
                <?php } ?>
                <h4><?php the_title(); ?></h4></a>
                <?php the_excerpt(); ?> 
            </div>

        <?php } ?>
    </div><!--row-->

    <?php } else { ?>
    No Post
    <?php } ?>
</div>
<div class="large-3 columns">
    <?php get_sidebar(); ?>
</div>
</div>

 <?php get_footer(); ?>

ANSWER

This did the trick

$news_page = get_queried_object(); echo $news_page->post_title;

3
  • Thanks Pieter. this worked $news_page = get_queried_object(); echo $news_page->post_title;
    – user742736
    Commented Jun 19, 2014 at 14:27
  • Please be kind and give Eric an upvote if you can :-) Commented Jun 19, 2014 at 14:31
  • Not enough reps.
    – user742736
    Commented Jun 19, 2014 at 14:33

0

Browse other questions tagged or ask your own question.