Support » Fixing WordPress » Show posts that belong to category x and y

  • I’m about to set up a site that uses categories in a rather different way than most sites do.

    At the moment I’ve got two category parents (say “People” and “Product”). Each of these have several children each. When you first enter my site, only sub-categories of “People” are shown.

    If you click on one of the “People” categories, you’re taken to a page that shows all posts that belong to that specific category (default WordPress behavious), and in the sidebar a new navigation pops up with children of the category “Product”.

    What I’d like to achieve is that clicking one of the categories in the sidebar takes you to posts belonging to both the selected “People” and “Product” categories.

    To simplify what I’m asking for, imagine this:

    • You enter my site
    • You click on the “People” sub-category “Boy”
    • You’re taken to a page showing all posts belonging to the category “Boy”, and a new category list “Products” shows up in the sidebar
    • You click on the sub-category “Toys”
    • You’re then taken to a page showing all posts belonging to both the category “Boy” and “Toys”

    Is this achievable?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Anyone? I really need help with this.

    Actually, I ran into the same problem since I wanted to have multiple pages with the same categories (like a certain production with always a submenu that containts its own reviews, description, etc.). I referred to the wp_loop wordpress hack that does the following:

    <?php query_posts(‘category_name=name&showposts=10’); ?>

    place this above your wp-loop and you will have 10 posts showing only from category “name”. Now, if you want posts to appear from two categories only, it would appear you will only have to add another category to the query like this:

    <?php query_posts(‘category_name=name&category_name=name2&showposts=10’);

    (The showposts query is optional by the way). The problem with this is though that it doesn’t exlude the posts when only looking in ONE category (If you look on category “name” only it will also show the posts that contain both “name” AND “name2” categories). Besides, it also shows the posts of the last category you added to the wp-query (name2) so it’s not working as it might seem. any suggestions?

    Quickie answer: I used UTW (Ultimate Tag Warrior) to accomplish this after searching for a way through just categories. Can use the “and” search to get both categories. See search page that comes with UTW.

    Hope that helps.

    – Bradley

    i posted something in another topic that might help:

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show posts that belong to category x and y’ is closed to new replies.