WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] static front page with the latest post

[Resolved] static front page with the latest post

  • Hi folks,

    i got an static front page and a post site running.
    But i wan’t to have always the latest post on my static front page.
    Is that possible? If yes, how?

    thanks a lot

Viewing 5 replies - 1 through 5 (of 5 total)
  • yes. see this link http://chinmoy29.wordpress.com/2010/08/04/display-latest-post-on-static-php-page/

    If your static page is .html then change the file extension to .php .

    Try this:

    <?php
     $postslist = get_posts('numberposts=1');
     foreach ($postslist as $post) :
        setup_postdata($post);
     ?>
            <div class="post"><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_content() ?>
    </div>
    <?php endforeach ?>

    @nathan12343

    Code works great. Many thanks.
    I am using it on a static front page with a template I created.

    Hi Guys,

    The code above by Nathan12343 works well. Using the editor I have placed the code into the “Page.php” template and the most recent post shows up under the static homepage. HOWEVER, these latest posts also show up for all the rest of my other pages… I only wish for it to show up on the homepage. I’ve tried putting the code into the “index.php” file but this isn’t working either. Anyone’s suggestions would be greatly appreciated!!!

    Thanks

    I’m using TwentyTen theme. Where to put the code in the page.php? It has loop.php seperately.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] static front page with the latest post’ is closed to new replies.