Support » Plugins » Mini-loop – little code tweak help

  • Resolved pcwp


    I am using the mini-loop on a home page. I want to display the post content.
    Also I would maybe like to display the excerpt instead.
    This code is successful in fetching the latest post and displaying the title. How can I get it to display the content and how could I get it to display the excerpt?

    require_once("/wp-config.php"); ?>

    <ul id="whats-new">
    $news=$wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts
    post_status= \"publish\" ORDER BY 'ID' DESC LIMIT ".$how_many);
    foreach($news as $np){
    print ("<li><a href=\"");
    echo get_permalink($np->ID);
    print ("\">$np->post_title</a></li>");
    } ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)


    Add post_content and post_excerpt to the SELECT statement, so you’re getting those columns. Then add output of $np->post_content to your foreach loop.



    perfect and wonderful –
    thanks Otto

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Mini-loop – little code tweak help’ is closed to new replies.