Support » Themes and Templates » Display posts from selected categories in a page

  • Hi all,

    I have a few categories which i named Media Releases, In The News and Events. I want to display all posts (the post links) from these categories in a page.

    Currently this is what i’m doing:
    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("showposts=5&paged=$page&cat=14&cat=3&cat=9"); while ( have_posts() ) : the_post(); $loopcounter++; ?>

    If you notice, i use cat=14&cat=3&cat=9 to display post links from the 3 categories i mentioned earlier. The numbers are the category numbers.

    I thought i have succeed to do it because at the first place, i only post content to the category number 9 (cat=9). Just now i write a content which fall under the cat=14 and cat=3. Unfortunately, the page still showing contents from cat=9 only. I try to change the sequence to
    cat=9&cat=3&cat=14 and now the page is only showing post under cat=14. So i can say that it only show the last category.

    Can anyone help me to display the other 2 categories?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Sending 3 requests like that isn’t the best choice, I believe. You could place them together (like in cat=3,9,14) and have the code sparse that for you. Using then a while function.

    foreach function, sorry.

    its working when i put comma like that..but the loop still using while function.


    I’m looking at displaying posts from a category in a page. (The rest of my pages need to remain as pages). Is what you are doing here doing just that? What other code/modifications do you have to your theme to enable it to work and where are you placing the code you have provided above?

    Thanks in advance for any help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display posts from selected categories in a page’ is closed to new replies.