WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] static front page with the latest post (6 posts)

  1. mabi404
    Member
    Posted 3 years ago #

    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

  2. chinmoy
    Member
    Posted 3 years ago #

    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 .

  3. nathan12343
    Member
    Posted 3 years ago #

    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 ?>
  4. Raymond
    Member
    Posted 3 years ago #

    @nathan12343

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

  5. olygao
    Member
    Posted 3 years ago #

    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

  6. Anuradha Edirisuriya
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic