Title: Mini loop on static frontpage
Last modified: August 18, 2016

---

# Mini loop on static frontpage

 *  [selder2](https://wordpress.org/support/users/selder2/)
 * (@selder2)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/mini-loop-on-static-frontpage/)
 * I’m using a miniloop on my static frontpage.
    This is the code for this miniloop:`
   <? $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>"); }?>
 * This displayes the last 6 posts on my weblog in a small list. This is cool and
   works like a charm.
 * But, however, I would like to have displayed the most recent posts in a certain
   category (e.g. “Software”)
 * I tried adding the following code to that miniloop
 * `WHERE `post_status`= \"publish\" AND `post_category`= \"Software\" ORDER BY '
   ID' DESC LIMIT ".$how_many);`
 * But that doesn’t work, it keeps displaying posts from all caterogies.
 * I went to my PHPadmin, and took a look at the wp_post table, and found that the
   column “post_caterogy” is always “0”, I guess that’s the reason why my code isn’t
   working…
 * How do proceed?

Viewing 1 replies (of 1 total)

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [20 years, 6 months ago](https://wordpress.org/support/topic/mini-loop-on-static-frontpage/#post-288320)
 * Maybe this topic can help: [http://wordpress.org/support/topic/38046](http://wordpress.org/support/topic/38046)

Viewing 1 replies (of 1 total)

The topic ‘Mini loop on static frontpage’ 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, 6 months ago](https://wordpress.org/support/topic/mini-loop-on-static-frontpage/#post-288320)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
