Support » Plugins » Latest post on static page

  • Resolved Red1


    I’d like to be able to position the latest (single) post of my “news” category on a static page we use as a home/index page.

    Is there a solution available?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Add this to a page template to display one post from category 17:

    $args = array(
      'numberposts' => 1,
      'cat' => 17
    if ($posts) {
    foreach($posts as $post) {
    <p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php the_content(); ?>
    <?php }

    Thanks for that Michael.
    I have managed to get the post in the page. My problem is position and format. I would prefer it positioned under the first block of introductory text and formatted as per the standard css for a post.
    If you have time to look and advise
    I would be most grateful.
    Many thanks

    I have another issue with the response.
    The posts are now appearing on all “pages”.
    I’ve saved the original page.php as page1.php in the hope of using it as a template and then remove the new code from the original page.php, but as a novice I’m unsure how to go about it.


    You need to assign page1.php as the Template on the Page. So edit that Page in your admin and point to page1.php as the template. If page1.php does not show as a choice then read this: Why is there no Page Template option when writing or editing a Page?

    Michael, your code above is different from the normal loop for a ‘single.php’ page. How would I code so that the post shown on the page is the same as a regular post?

    EDIT Got it working, but previous_post_link and next_post_link don’t appear, I guess because they aren’t in The Loop?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Latest post on static page’ is closed to new replies.