I have a category called News and a custom Taxonomy called Filters which is a hierarchical Taxonomy.

When a user creates a Post, they select a subcategory under news and a sub-filter under the Filter Taxonomy.

Now I am trying to list all the ‘Sub-Categories’ and ‘Filters’ when a user navigates to /news.

Listing the Sub-Categories for the ‘News’ category was easy. But I can’t seem to figure out a way to list all the ‘Sub-Filters’ for the Taxonomy ‘Filters’ limited to only the category ‘News’.

Here is the code I used for getting a list of sub-categories for the category news:

function get_child_categories()
{
    if (is_category()) {
        $thiscat = get_category(get_query_var('cat'));
        $catid = $thiscat->cat_ID;
        $args = array('parent' => $catid);
        $categories = get_categories($args);

        return $categories;
    }

    return false;
}

I was hoping for a similar function which will list all terms for taxonomy ‘Filters’ but only limited to the category ‘News’.

Read more here: Get a list of Terms for a specific category


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: