Skip Navigation

[Resolved] Nested Taxonomies setup – newbie question

This support ticket is created 8 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Minesh 8 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#360596

I am trying to create a View that filters "plants" by the "month" selected. The view would consist of 4 sections:
"Prune this Month:"
"Don't Prune this Month:"
"Feed this Month:"
"Don't Feed this Month:"

I figured I would setup the custom taxonomy for as such (unless there is a better way!):
-January
--Prune in January
--Don't Prune in January
--Feed in January
--Don't Feed in January
-February
--Prune in February
--...etc

Would this View be accomplished by creating a Master view where the user chooses the month, that has 4 views inside for each section?

One problem is that all of the Child taxonomies would show up in the selector instead of just the parent Months.

Thanks so much for any help!

#360645

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I think yes - all four view will work inside master view.
You mean you want to display only parent taxonomy title with your taxonomy dropdown filter?

#360845

Sure, I will try that, How do you display only parent taxonomy Title with the master view dropdown filter?

#360951

Minesh
Supporter

Languages: English (English )

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

You mean - you want to only display parent taxonomy terms with your taxonomy filter dropdown?

#360972

yes

#360977

Minesh
Supporter

Languages: English (English )

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

View taxonomy filter will include all child term by default, you can try views filter hook to alter it, like this:

Add codes in your theme/functions.php

add_filter('wpv_filter_query', 'taxonomy_view_func', 10, 2);
function taxonomy_view_func($query, $setting) {
    if($setting['view_id'] = 123)
    {
        if(isset($query['tax_query']))
        {
            foreach($query['tax_query'] as $k => $v)
            {
                if(isset($v['taxonomy']) && $v['taxonomy'] == 'category')
                {
                    $query['tax_query'][$k]['include_children'] = false;
                    break;
                }
            }
        }
    }
    return $query;
}

Please replace 123 with your VIEW #3 post ID, replace "category" with your custom Taxonomy slug.

More help:
Views Filters – Extend Views
https://toolset.com/documentation/user-guides/views-filters/
include_children
http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.