Skip Navigation

[Resolved] List of child category for a specific parent category

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 6 replies, has 2 voices.

Last updated by jean-francoisB 1 year, 7 months ago.

Assigned support staff: Minesh.



Page showing the issue :

I got your help to put the list of all Main category on this page : hidden link (ticket :

Now I try to get something more complete. With a mouse over a taxonomy, I want a list of child taxonomy displayed in a Tooltip window. So for now, it's working well, but showing the complete list of categories in the listing-category taxonomy. So I ONLY want the child category of that specific parent category that the mouse is over.

This is the code in my function.php that display this taxonomy list :

add_filter('wpv_filter_taxonomy_query', function($query, $settings, $views_id){
    if($views_id == 412 && isset($_GET['wpv-listing-category'])){
        $term = get_term_by('slug', $_GET['wpv-listing-category'], 'listing-category'); // here replace "listing-category" with your custom taxonomy slug
$query['parent'] = $term->term_id;
    return $query;
}, 99, 3); 

add_shortcode('get_term_by_url_param', function($atts){
    $res= '';
    $atts = shortcode_atts( array(
        'url_param' => 'wpv-listing-category',
        'tax' => 'listing-category',
    ), $atts);
    if(isset($_GET[$atts['url_param']]) && $_GET[$atts['url_param']] != ''){
        $term = get_term_by('slug',$_GET[$atts['url_param']], $atts['tax']);
            $res = '<strong>Category :</strong> '. $term->name;
    return $res;

This is the code for the Loop item in Listing category list

{tooltip}<a href="?wpv-listing-category=[wpv-taxonomy-slug]">[wpv-taxonomy-title]</a>{end-text}[xyz-ips snippet="childcat"]{end-tooltip}

So the Tooltip shortcode is from a plugin that allow me to publish tooltip.

So everything displayed in the tooltip is included in : [xyz-ips snippet="childcat"]

This is the code that I have in this PHP snippet :

// List terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)
$toolsetslug = do_shortcode('[wpv-taxonomy-slug]');
$category = get_category_by_slug($toolsetslug);

$taxonomy     = 'listing-category';
$orderby      = 'name'; 
$show_count   = false;
$pad_counts   = false;
$hierarchical = true;
$title        = '';
$args = array(
  'taxonomy'     => $taxonomy,
  'orderby'      => $orderby,
  'show_count'   => $show_count,
  'pad_counts'   => $pad_counts,
  'hierarchical' => $hierarchical,
  'title_li'     => $title,
'child_of ' => $category->term_id,
'hide_empty'          => 0
    <?php wp_list_categories( $args ); ?>

So wp_list_categories publish the full category list. So I need to specify the 'child_of' to make sure that I get the subcategories of the category my mouse is over. To get this category ID, I have created $toolsetslug with do_shortcode to be able to use [wpv-taxonomy-slug] shortcode. $category is there to get the ID from that slug. I didn't find an easier way to get the category ID.

I'm maybe wrong in my code. I'm very newbie and I got pieces of code in different forums. But I still have a feeling that I'm not too far to get what I'm looking for.

Any idea what I could change in this code to get it working?

Thank you very much!



Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I'm not sure why you make such things too complicated by adding such custom code when you can achieve the same thing using Toolset only.

Can you please check: hidden link

I've created the following child taxonomy view:
=> hidden link

And added the above view to the following view:
=> hidden link
we are displaying the "child-listing-category-tooltip" listing view as given under:

{tooltip}<a href="?wpv-listing-category=[wpv-taxonomy-slug]">[wpv-taxonomy-title]</a>{end-text}[wpv-view name="child-listing-category-tooltip"]{end-tooltip}
Capture d’écran, le 2020-02-24 à 12.38.43.png


Thank you for your help. But now I'm getting an error message on this page : hidden link

See attached. Let me know if you can fix that.

Thank you,



Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It must be the cache. I can see the page is working as expected. Please check the following screenshot:
=> hidden link

Please clear browser as well as server cache and it should work OK.


Hi Minesh! You were right, clearing the cash solved this issue. It's now working very well!

Just a little detail. For the sub-category that is published in the tooltip, is it possible to make the links look like the main category link?

Actual link of subcategory : hidden link
Desired link of subcategory : hidden link

Thank you!



Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - that's possible:

With the following view, I've changed the "Loop Editor section" content as given under:
=> hidden link

<a href="?wpv-listing-category=[wpv-taxonomy-slug]">[wpv-taxonomy-title]</a>

I can see with child taxonomy terms it's displaying now expected URLs.


Thanks Minesh! You are the best! You have been really useful to get my issues solved quickly. Thanks!

My issue is resolved now. Thank you!