Skip Navigation

[Resolved] View Query Filer: Taxonomy the smae as the page where this View is shown issues

This support ticket is created 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Christian Cox 4 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1401783

I am trying to:
I'm trying to use the views to display "Promotions" content in the side bar of pages with the same custom taxonomy "Destination".

Link to a page where the issue can be seen:
You can see that this "Promotion" We'll Call it Promotion #1 (only visible in the side bar so the "template" is not set up nicely.) Has the Destination Taxonomy = Adelaide, Between Adelaide and Kangaroo Island, Between Melbourne & Adelaide. hidden link

This "Promotion" We'll Call it Promotion #2 has the Destination Taxonomy = Australia hidden link

I expected to see:
I expect that on a page like: hidden link Where the "Destination" Taxonomy includes "Australia" but does not include " Adelaide", "Between Adelaide and Kangaroo Island", "Between Melbourne & Adelaide" that Promotion #1 will not show in the side bar, while Promotion #2 will show in the side bar.

Instead, I got:
Promotion #1 shows up on all pages, even when the custom Destination taxonomy does not match the taxonomy of the Promotion.

Please note, our site is under development with Restricted Access to the content. I have not provided wordpress log-in, but have provided the credentials to view the pages in that area.

#1402303

Hi, based on your description of the View configurations, I would not expect the results I'm seeing here, either. However, I'm not able to see the full View configurations and context so it's a bit difficult to tell. For example, if the View's Query Filters contain other taxonomy filters, then it's possible the filters are combined using "OR" instead of "AND". In this case matches in any of the other taxonomy custom filters would cause a result to appear. Can you take screenshots showing the entire View editor screen for this View? If the Query Filter panel is not active, please scroll to the top right corner and click "Screen Options" to enable the panel.

I would also like to know more about how the View is inserted in the sidebar here. Are you using a widget, or a shortcode, or some custom PHP to render the View? Can you share any code or a screenshot that indicates how the View is inserted?

On the page where the Adelaide custom quote result can be seen in the sidebar, what type of post is this? Is it a custom Page with a View inserted, or a custom post type, an archive, etc?

Next, I'd like to try a few more troubleshooting steps to help narrow down the problem.
- Temporarily switch to a default theme like Twenty Twenty or Twenty Nineteen and deactivate all plugins except Types and Views. If you have any custom code in Toolset > Settings > Custom Code, temporarily deactivate it.
- If you need to activate a Maintenance Mode plugin during testing, that's fine.
- Test the View again. If you cannot see the View on the screen because you have disabled a plugin that was responsible for displaying it there, place the View directly in the post content using the Fields and Views button above the post editor.
- If the problem is resolved, reactivate your custom code, theme and other plugins one by one until the problem returns.
- If the problem is not resolved, I'll have to take a closer look.

#1402995
Destinations Taxonomy Structure.png
Destinations Taxonomy Setting.png
Adelaide Custom Quotes.png
Widget.JPG
Views Full Page.png
Query Filter.JPG

Hello Christen,

Thank you for your reply. I have attached the screen shots as requested. Can you take a look and see if you can determine if anything in the settings is causing this problem? The Adelaide custom quote results is showing up on all Pages and Posts with the "Sidebar Right" Widget.

One thing I thought, was that "Adelaide, Between Adelaide and Kangaroo Island, Between Melbourne & Adelaide" Destination Taxonomy are sub taxonomies of "Australia". In fact "Australia" is the parent Taxonomy for all current destinations - however I did not select "Australia" in the Custom Adelaide promotion. I thought maybe since they all have the same parent. Could that affect the Query Filter? I've also attached screen shots to help you see the structure and settings of the Taxonomy.

#1403063

Sorry but there must have been a problem during the reply submission - I didn't receive any attachments. Can you try submitting your reply and images again?

#1403155
Query Filter.JPG
Widget.JPG
Views Full Page.png
Adelaide Custom Quotes.png
Destinations Taxonomy Setting.png
Destinations Taxonomy Structure.png

Hello Christen,

Thank you for your reply. I have attached the screen shots as requested. Can you take a look and see if you can determine if anything in the settings is causing this problem? The Adelaide custom quote results is showing up on all Pages and Posts with the "Sidebar Right" Widget.

One thing I thought, was that "Adelaide, Between Adelaide and Kangaroo Island, Between Melbourne & Adelaide" Destination Taxonomy are sub taxonomies of "Australia". In fact "Australia" is the parent Taxonomy for all current destinations - however I did not select "Australia" in the Custom Adelaide promotion. I thought maybe since they all have the same parent. Could that affect the Query Filter? I've also attached screen shots to help you see the structure and settings of the Taxonomy.

#1404757

Okay thank you for the update, I can see the images now. It turns out that this is the default behavior of a hierarchical taxonomy filter, so posts that belong to a child term will show up in the results when filtered by one of that child term's ancestors. There is an API filter available that can suppress this behavior: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_tax_filter_include_children
To implement this filter you can create a new code snippet in Toolset > Setttings > Custom Code, or add the following custom code to your child theme's functions.php file:

add_filter('wpv_filter_tax_filter_include_children', 'no_child_term_func', 100, 3);
function no_child_term_func($include_child, $category_name, $view_id){
    if($view_id == 55411 && $category_name == 'destination'){
        $include_child = false;
    }
    return $include_child;
}

Let me know if you have questions about this API filter, or if you have trouble implementing it and getting the correct results.

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