Title: Mini Loop: exclude category
Last modified: August 18, 2016

---

# Mini Loop: exclude category

 *  [twotwentysix](https://wordpress.org/support/users/twotwentysix/)
 * (@twotwentysix)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/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)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 7 months ago](https://wordpress.org/support/topic/mini-loop-exclude-category/#post-280286)
 * Wouldn’t the [Template_Tags/query_posts](http://codex.wordpress.org/Template_Tags/query_posts)
   do the job?

Viewing 1 replies (of 1 total)

The topic ‘Mini Loop: exclude category’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [moshu](https://wordpress.org/support/users/moshu/)
 * Last activity: [20 years, 7 months ago](https://wordpress.org/support/topic/mini-loop-exclude-category/#post-280286)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
