WordPress.org

Ready to get started?Download WordPress

Forums

Mini Loop: exclude category (2 posts)

  1. twotwentysix
    Member
    Posted 8 years ago #

    I am using the mini code on a static page and so far it shows all the categorys.
    I would like it to shwo only one specific category (news)
    Help would be much appriciated.

    the mini loop:
    <?php
    $how_many=5; //How many posts do you want to show
    require_once("../core/wp-config.php"); // Change this for your path to wp-config.php file ?>
    <ol id="whats-new">
    <?
    $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 ("*<a href="");
    echo get_permalink($np->ID);
    print ("">$np->post_title</a><br>");
    } ?>
    </ol>

  2. moshu
    Member
    Posted 8 years ago #

    Wouldn't the Template_Tags/query_posts do the job?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.