Latest Posts on Static Front Page (3 posts)

  1. olidenson
    Posted 5 years ago #

    Hello, I'll keep it quick.

    I wanted my friend to be able to update their own home page text.

    I decided to create a "Home" Page and a "Blog" Page then change the "Reading" settings in admin to:

    Front Page= Home
    Posts Page= Blog

    I made a copy of the index.php and turned it into a template to apply to my new "Home" page.

    This works great as I now have a homepage that acts like the regular index page and also a Blog page for listing the latest posts.

    What i would now like to do is have a list of the two latest posts on my new Home page, but can only get it to display a bullet list using:

    <?php wp_get_archives('type=postbypost&limit=15'); ?>

    I basically want it to have the excerpt and eventually a thumb also.

    Any help would be entirely appreciated.


  2. poliquinp
    Posted 5 years ago #

    You could check this snippet of code.

    <?php query_posts('showposts=2&order=DESC'); ?>
        <?php if (have_posts()) : while (have_posts()) : the_post();?>
         [GET YOUR content EXEMPLE]
         <!-- The title of the post -->
         <php the_title() ?>
         <!-- The excerpt -->
         <?php the_excerpt() ?>
        <?php endwhile; endif; ?>

    With your query, you will be able to get the 2 lastest posts with the 'Showposts' and the 'order' by DESC.

    By using the query you will do your 'While' to get the two posts

    Hope it will help

  3. chinmoy29
    Posted 5 years ago #

    $my_query = new WP_Query('showposts=2');
    while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;

    Use this code. Hope it will help you.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.