Skip Navigation

[Resolved] Taxonomy Hierarchical Tree > Nested Views, need some help.

This thread is resolved. Here is a description of the problem and solution.

Problem:
Hide posts of parent category in the nested view (parent-child views).

Solution:
If you want to display the parent category but simply exclude the posts for this, you could use HTML conditional output in your Posts View.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/ > Checking if a post has a specific term assigned

For example, you can exclude multiple categories using conditional output with AND operator, like this:

[wpv-conditional if="( '[wpv-taxonomy-slug]' ne 'slug1' ) AND ( '[wpv-taxonomy-slug]' ne 'slug2' )"]
Content goes here
[/wpv-conditional]

Screenshot: https://d7j863fr5jhrr.cloudfront.net/wp-content/uploads/2017/06/537622-Exclude_multiple_categories.png?x72603

Relevant Documentation:
- Related thread: https://toolset.com/forums/topic/hide-posts-on-category-parent/#post-380505
- https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/

This support ticket is created 7 years, 5 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Noman 7 years, 5 months ago.

Assisted by: Noman.

Author
Posts
#537475

Hi,

We're creating a catering menu.

I followed the guide on nesting views and was able to create a list products grouped by Product Categories.
However I'm not sure how to use the same approach and add another parent level of Nesting that would group the Categories by Category Parents.

Currently my list looks like this:

Sub-category
- product
- product
Sub-category
- product
- product
Sub-category
- product
- product

I would like it to look like this:

Category
Sub-category
-product
-product
Sub-category
- product
- product
Category
Sub-category
- product
- product

The only workaround I could find at this point is hide(CSS) the container that holds the products that are being listed under the parent category so that only the parent category title remains visible.

However I'll be happy if we can just create a lighter database query instead of having to hide all these with CSS.

Thanks!

#537576

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Diyan,

Thank you for contacting Toolset support. If you want to display the parent category but simply omit the posts for this, you could use HTML conditional in your Posts View.
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/ > Checking if a post has a specific term assigned

We have another client who had the similar issue and was also able to solve it, this may help in your case, the known solutions mentioned here:
https://toolset.com/forums/topic/hide-posts-on-category-parent/#post-380505

Thank you

#537587

Hi Noman,

Thank you for looking into this.

Looks like the html conditional does the thing! Thanks for pointing me to that solution!

Just one thing, can you help me with the proper syntax in cases when I want to exclude multiple category slugs?

My current code:

 [wpv-conditional if="( '[wpv-taxonomy-slug]' ne 'slug1' )"]

What would be the proper syntax for excluding 'slug1' and 'slug2' and 'slug3' .. and so on.

Thanks!

#537622

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Exclude multiple categories.png

Yes, you can exclude multiple categories using AND operator, like this (screenshot attached):

[wpv-conditional if="( '[wpv-taxonomy-slug]' ne 'slug1' ) AND ( '[wpv-taxonomy-slug]' ne 'slug2' )"]
Content goes here
[/wpv-conditional]

Thanks

#537630

Awesome!

This worked, I didn't realized I could generate this with the UI. Thanks anyway!

D.

#537634

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Yes its possible using interface, I am happy to help you 🙂 Have a great day.

Thank you