Skip Navigation

[Resolved] Display a view only if a specific term has posts

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

Problem:

I wonder how to Display a view only if a specific term has posts ?

Solution:

I suggest you try with a taxonomy view, for example:

https://toolset.com/forums/topic/display-a-view-only-if-a-specific-term-has-posts/#post-1294449

Relevant Documentation:

https://developer.wordpress.org/reference/classes/wp_term_query/__construct/

This support ticket is created 5 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by romanB-3 5 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1294073

Hello,
I wonder how to Display a view only if a specific term has posts ?
Thank you.

#1294449

Hello,

I suggest you try with a taxonomy view:
- Query terms of your taxonomy
- in section "Query Options", enable option "Don't show empty terms"
- filter by:
Taxonomy is One of these: your specific terms
- in section "Loop Editor", within shortcodes [wpv-items-found] ... [/wpv-items-found]
display your what you want(other view shortcode ... etc)

More help:
https://developer.wordpress.org/reference/classes/wp_term_query/__construct/
'hide_empty'
(bool|int) Whether to hide terms not assigned to any posts. Accepts 1|true or 0|false. Default 1|true.

https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found
Meta HTML wrapped in [wpv-items-found][/wpv-items-found] will be output if there are any posts | taxonomies | users returned by the View.

#1294821

My issue is resolved now. Thank you!
Just great, thank you.