Forums

Pulling in additional fields in a Mini-Loop? (1 post)

  1. fueler
    Member
    Posted 5 years ago #

    I have WordPress installed in a subfolder 'articles' and wish to pull the 3 recent posts along with their teaser and picture into my static home page...but I can't get that to work.

    I'm using this mini-loop:

    <?php
    $how_many=3; //How many posts do you want to show
    require_once("articles/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_status</code>= \"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>");
    } ?>
    </ol>

    ...this works in pulling in the post titles, but I want to pull in their their teaser and picture as well....I've tried modifying but no luck.

    Any suggestions?

    btw...Those extra codes in the code above are actually backticks...I used backticks to post this code..then the backticks in the code now display the word code

    Thanks!`

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags