• Hi, if I use a static page as a main page for my blog (so not the last post), how can I show a preview of the last post published? (or latests 5 for example).

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Use The Loop with query_posts.

    Thread Starter snakesmaster

    (@snakesmaster)

    Can you give an example pls? What’s the code to put inside a static page to show a preview of the last post published? Thanks buddy!

    1 – Create a page template to use for your main front page :
    http://codex.wordpress.org/Pages#Page_Templates

    Let’s say you name this template file : template_index.php

    2- Use this template for your main page =>wp-admin => edit page =>page template

    3- Then edit this template file as renato_s said, with a query post and a loop anywhere you want the last 5 posts to appear :

    <?php query_posts('orderby=date&order=DSC&showposts=5'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <strong>- do your stuff (title, permalink, date, author, excerpt, etc...) -</strong>
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>

    Note the query_posts statement : “orderby=date&order=DSC&showposts=5”

    you adjust the “showpost” variable to the number of post you want to display… In my example, it’s 5…

    S.

    Thread Starter snakesmaster

    (@snakesmaster)

    THANKS!!!!!!!

    Thread Starter snakesmaster

    (@snakesmaster)

    HI again, is it possible to make the preview whit an image too? Like this site… http://pshero.com/page/4 (I don’t know if it’s done manually or with a query).

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Preview posts in a static page’ is closed to new replies.