Forums

Preview posts in a static page (6 posts)

  1. snakesmaster
    Member
    Posted 3 years ago #

    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!

  2. renato_s
    Member
    Posted 3 years ago #

    Use The Loop with query_posts.

  3. snakesmaster
    Member
    Posted 3 years ago #

    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!

  4. SimonJ
    Member
    Posted 3 years ago #

    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.

  5. snakesmaster
    Member
    Posted 3 years ago #

    THANKS!!!!!!!

  6. snakesmaster
    Member
    Posted 3 years ago #

    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).

Topic Closed

This topic has been closed to new replies.

About this Topic