WordPress.org

Support

Support » How-To and Troubleshooting » Mini Loop: exclude category

Mini Loop: exclude category

  • 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>

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Mini Loop: exclude category’ is closed to new replies.
Skip to toolbar