WordPress.org

Ready to get started?Download WordPress

Forums

Show posts that belong to category x and y (5 posts)

  1. syff
    Member
    Posted 7 years ago #

    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?

  2. syff
    Member
    Posted 7 years ago #

    Anyone? I really need help with this.

  3. martentiman
    Member
    Posted 7 years ago #

    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?

  4. likoma
    Member
    Posted 7 years ago #

    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

  5. malheiro
    Member
    Posted 7 years ago #

    i posted something in another topic that might help:

    http://wordpress.org/support/topic/118978?replies=11#post-570482

Topic Closed

This topic has been closed to new replies.

About this Topic