WordPress.org

Ready to get started?Download WordPress

Forums

Children posts from multiple categories (1 post)

  1. xdera
    Member
    Posted 1 year ago #

    Hello everyone!

    Going to "mysite.com/category/my_city/restaurants/" I can display all the posts that are under category "my_city" AND under category "restaurants".

    Let's assume that restaurants category has several childs (thai, italian, etc): how can i make a list of all children subcategories of restaurants that are ALSO and ONLY under my_city category?

    For example "mysite.com/category/my_city/thai/"

    For the moment this is the code in my category.php file:

    <?php
    $this_cat = (get_query_var('cat')) ? get_query_var('cat') : 1;
    $this_category = get_category($this_cat);
    if ( $this_category->parent ) { $this_cat = $this_category->parent; }
    wp_list_categories('title_li=&child_of=' . $this_cat . '');
    ?>

    The results is a list like "thai, italian, etc" (that apparently is good), but the links are all pointing to something like "mysite.com/category/restaurants/thai/", showing ALL restaurant, not only those under my_city.
    Obviously I'm not catching the other category and don't know how to do the right array.

    Thanks a lot in advance for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic