• I have two categories: Blog and Listings, and was wondering if WordPress can show just my Blog posts on the home page and my Listings on another page. In other words, certain categories only show up on certain pages. I’m assuming there is some sort of “IF” statement, but I’m not sure where to start.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Have you read this? Hope it can help!

    Thread Starter get_username

    (@get_username)

    Hi Carlla,

    That helped quite a bit and believe I can get it to work that way. One question though; how do I target specific areas on the page? For example, I want one blog post to show up in the content area, and the listing post to show up in the sidebar. I’m able to get the listing posts in the sidebar, but as soon as I tell the blog area to only show blogs and not listings, it clears out my sidebar.

    Thanks,
    Burt

    Thread Starter get_username

    (@get_username)

    I think I figured out one of my questions. To clear a query and not have it affect my sidebar I put in this at the end:

    <?php endif; wp_reset_query(); ?>

    Now for some reason–event though I’ve said to show only two posts–it still shows all of them.

    <?php query_posts($query_string . '&posts_per_page=2'); ?>

    The code shows all instead of 2 per page.

    Thread Starter get_username

    (@get_username)

    It seems as though you can’t show these two lines together:

    <?php
    	query_posts('showposts=1');
    	query_posts($query_string . '&cat=9');
    
    	if ( have_posts() ) : while ( have_posts() ) : the_post();
    ?>

    If I take out the category listing the single post works. So I guess now the question is, how do you show a single post and category together?

    Thread Starter get_username

    (@get_username)

    Hmmm, it seems as though this works better than the above. Can anyone explain why? Is there anyone even reading these posts? ??

    <?php query_posts('category_name=blog&showposts=2'); ?>

    If you call the query_posts twice you are overwriting the query, making a new Loop. Only the second query will works.

    when you want to add parameters just add a "&" between them
    eg: category_name=blog&showposts=2&author=2

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can WordPress filter a post based on category?’ is closed to new replies.