Support » Fixing WordPress » Single (latest) post on page, with comments?

  • Resolved Snaggletooth



    I want to place exactly one post on a page. It would be nice if this post could automatically be the latest one but updating manually would be OK too.
    What I have done so far is
    – creating a new custom page template and assigned that to the page that should display the post.
    – setting that page to be the posts page in Settings->Reading and allow only one post to be displayed there.

    Now what happens is that I do indeed see the latest post there, BUT:
    – it uses index.php as template instead of my custom template.
    – it shows the post without comments and the submit form (comments_template() doesn’t work)

    I have also tried to solve the problem by not setting that page as the ‘posts page’ but by retrieving the lastest post with get_post($id).
    This basically also works but again I am out of luck with the comments because comments_template() gives me the comments for that page and not for the post on it.

    Can someone help me please – I have searched around but just couldn’t find any solution here or elsewhere…

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • As you found out, you can’t use a template on the Blog page. But, you can create a template for another page that just displays the one most recent post. The exact coding will depend on your theme, but the query should be similar to this:

    $args = array(
       'caller_get_posts' => 1,  // Don't put stickies at top
       'posts_per_page' => 1,

    This should be followed by the rest of the code for the Loop.

    Thank you. That was very helpful. The problem is still not completely solved though.
    Calling comments_template() does not work so I tried get_template_part(‘comments’) that for some reason only returns the submit form. Now calling get_comments() lists the comments but I would need to place all the html from comments.php again (what I don;t feel like doing).

    Another problem is, that the next_posts_link() and previous_posts_link() don’t work anymore. They return a url like this: …/?page_id=6&paged=2

    What I did for a workaround now is using the query_posts() function from above to retrieve the permalink of the latest post and using this link in the navigation. Like this the content is displayed through single.php so that I have the full post, the comments and the previous/next post links. Disadvantage of this is that the url in the main navigation is always changing with a new post.

    By the way – the theme I am working with is a customized Empty Canvas

    Does someone have an idea how to tackle the problem of displaying the post on a page using the comments.php template and with working previous/next links?

    To allow pagination to work, use this:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
       'caller_get_posts' => 1,  // Don't put stickies at top
       'posts_per_page' => 1,
       'paged' => $paged,

    Calling comments_template() should work if used in the Loop. Did you place it outside the Loop, by chance?

    Thanks again. Pagination works now. And you are right – comments_template() was placed outside the loop. But now that it’s inside it still won’t work (sigh).

    Can you post a few lines of code containing your loop, or copy the file to the pastebin and post that link here, so the code can be examined?

    Sorry this is all going a bit slow…
    Here is the code:

    OK – please try setting $withcomments = 1;, like this

    <?php $withcomments = 1; ?>
    <?php comments_template(); ?>

    YES! It works. Thank you so much. The documentation is not very intuitive. What a luck there are people like you. Have a great weekend.

    You are welcome!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Single (latest) post on page, with comments?’ is closed to new replies.