Skip Navigation

[Resolved] Conditional output on post count of taxonomy

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

Problem:
Conditional output on post count of taxonomy

Solution:
You should use nested view's in order to display post count with post details.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/custom-search-is-ignoring-input/#post-628762

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-attribute
=> https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found

This support ticket is created 6 years, 1 month 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)

This topic contains 3 replies, has 3 voices.

Last updated by Minesh 6 years, 1 month ago.

Assisted by: Minesh.

Author
Posts
#626731

Hi is the following possible, or can you point me in the correct direction...

I have two CPT's that share the same taxonomy:
CPT 1: Sector Reports
CPT2: Companies
Taxonomy: Sectors

What I would like to do is to create a listing of Sectors that have at least one CPT Sector Reports Linked to them.

I know the shortcode for post-count, but that has no attributes... so it will return the total amount CPT1 + CPT2...

I only want to display a sector name if there is at least one CPT1 post type is linked...

Any idea?

Best regards,
Herre

#626823

Dear Herre,

I think it is possible within a nested view, for example:
1) Parent view lists terms of taxonomy "Sectors", in view's loop, display below child view, and pass term's ID as the shortcode attribute to child view, for example:
[wpv-view name="child-view" wpvsectorsid="[wpv-taxonomy-id]"]

2) Child view "child-view" list "Sector Reports" posts, filter by:
Select posts with taxonomy:
Sectors set by the parent Taxonomy View

https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/
Value set by parent Taxonomy View

in section "Loop Output Editor", within shortcode [wpv-items-found] ... [/wpv-items-found], display term id from parent view:
[wpv-attribute name="wpvsectorsid"]

With the term id, you can display term's other information, by specifying "id" attribute of Views shortcodes, for example:

Term's title:
[wpv-taxonomy-title id="[wpv-attribute name="wpvsectorsid"]"]
Term's link:
[wpv-taxonomy-link id="[wpv-attribute name="wpvsectorsid"]"]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-attribute

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.

#628208

Thank you for your reply, will try your approach and see if it works...

#628276

Minesh
Supporter

Languages: English (English )

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

Luo is on vacation. This is Minesh here and I'll take care of this ticket and try to help you further. Hope this is Ok.

Let me know if you need further assistance.

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