• selder2

    (@selder2)


    I’ve got a mini-loop running on the welcome page of my blog:

    <?
    $news=$wpdb->get_results("SELECT
    ID,post_title FROM $wpdb->posts
    WHERE
    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>");
    }
    ?>

    Is it possible to have the titles from 1 certain category displayed? The loop above displays the last 6 posts, but I would like to display the last 6 posts in a certain category …

    I’m thinking AND post_category = something, but! when I look in the WordPress MySQL database, I see that the column for post_category is always zero…

    Anyone an idea on how to have just posts from a certain category displayed?

Viewing 3 replies - 1 through 3 (of 3 total)
  • moshu

    (@moshu)

    Why not use the Template_Tags/query_posts that has the built-in capacity to pick whichever category you want…

    Thread Starter selder2

    (@selder2)

    Thanks, that is indeed a very usefull option.

    Any idea how I use that to display the last 6 posts? I can’t find the variable for that anywhere :/

    Thread Starter selder2

    (@selder2)

    ok ok, I suck, the variable to use is right in the aboce link :p

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Mini loop with post titles from 1 category’ is closed to new replies.