Forums

Problem with static page as index & mini-loop (1 post)

  1. tezwildecat
    Member
    Posted 3 years ago #

    Hi,

    I've followed the instructions on the WordPress Codex, regarding how to include a mini-loop on my static index page.

    The mini-loop code is brilliant, but I'm unable to include the date of each post.

    <?php
    $how_many=5; //How many posts do you want to show
    require_once('wp-config.php'); // Change this for your path to wp-config.php file ?>
    
    <ol id="whats-new">
    <?
    $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts
    WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
    foreach($news as $np){
    printf ("<li><a href=\"index.php?p=%s\">%s</a></li>", $np->ID,$np->post_title);
    }?>
    </ol>

    I guess it's a really simple line, but everything I've tried so far hasn't worked.

    Any help would be really appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic