Support » Fixing WordPress » Displaying 5 latest post on my external homepage

  • danshaw


    I am using the following code to display my 5 most recent post headlines on my homepage, which is 1 level up from my WP installation:

    $how_many=5; //How many posts do you want to show
    require_once(“articles/wp-config.php”); // Change this for your path to wp-config.php file ?>
    <ul id=”whats-new”>
    $news=$wpdb->get_results(“SELECT ID,post_title FROM $wpdb->posts
    WHERE post_status= \”publish\” ORDER BY ‘timestamp’ DESC LIMIT “.$how_many);
    foreach($news as $np){
    print (”

  • <a href=\””);
    echo get_permalink($np->ID);
    print (“\”>$np->post_title
  • “);
    } ?>

    This appeared to be working fine at first, up until I had written more than 5 posts, now this code doesnt seem to display the newest ones, only the first 5 ever posts

    I have tried replacing timestamp with date as the ORDER BY setting

    Any ideas?


  • The topic ‘Displaying 5 latest post on my external homepage’ is closed to new replies.