Posted By

vagrantradio on 02/18/10


Tagged

wordpress id posts categories showposts


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

booski


Wordpress display posts in category based on page.


 / Published in: PHP
 

Had many people ask me how I display all posts in a category when they click on the category link in the header @http://www.vagrantradio.com.

There's a lot more involved, but here's the quick and dirty;

  1. //if is articles page, get posts from this category id and show 9 of them.
  2. <?php
  3. if (is_page('7') ) {//articles
  4. query_posts('cat=4&showposts=9');
  5. } elseif ( is_page('9') ) {//freebies
  6. query_posts('cat=5&showposts=9');
  7. } elseif ( is_page('356') ) {//inspiration
  8. query_posts('cat=30&showposts=9');
  9. } elseif ( is_page('949') ) {//tutorials
  10. query_posts('cat=6&showposts=9');
  11. } else {
  12. $cat = '';
  13. }
  14. ?>

Report this snippet   <

You need to login to post a comment.