Skip Navigation

[Resolved] Displaying Checked (and Unchecked) Taxonomies for a specific Post in a View

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

Problem: I would like to list all the terms in a taxonomy on my single post page. If a term is assigned to the post, I would like to display a "check" icon next to the term name.

Solution: You can accomplish this with two Views: One View of the taxonomy and another View of the post filtered by term, where the term slug is set by a shortcode attribute. Use a glyphicon in the nested View to display a checkmark as needed.

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

This topic contains 3 replies, has 2 voices.

Last updated by Furlan 5 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1212706

Hi,

I need to display in a View certain characteristics(taxonomies) of a CPT called Profile.

For example:
One taxonomy called Sports and its terms: Swimming, Running, Cycling, Baseball, Basketball and Tennis,

What I want to display:
Sports that I practice and I don't:
- Swimming (yes)
- Running (yes)
- Cycling (no)
- Baseball (yes)
- Basketball (yes)
- Tennis (no)
(instead of "yes" or "no" a glyphicon or mark with a check or "x")

*It is important to display Sports that profile does not practice.

Resources that I visited:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/
https://toolset.com/documentation/user-guides/displaying-wordpress-term-fields/
https://toolset.com/forums/topic/showing-only-the-parent-taxonomy-and-showing-term-fields-in-a-content-template/
https://toolset.com/forums/topic/display-taxonomy-terms/

#1212785
query-filter.png

Hi, I can help you with this.
- Create a View of the Sports taxonomy called "All Sports Terms", and use the "Full custom display" option in the popup.
- Scroll down to the Loop editor and click "Loop Wizard". Create an unordered list display, and display the taxonomy title field.
- Exit the wizard and the loop will be generated automatically. Place this View in your Profile template as a test, and confirm that the taxonomy term titles are displaying as expected.
- Create a View of Profile posts called "Profile Term Glyph", and use the "Full custom display" option in the popup.
- Add a Query Filter by post ID, set by a shortcode attribute "ids"
- Add a Query Filter by Sports taxonomy term, where the term slug set by a shortcode attribute "terms" (see query-filter.png for an example)
- In the Loop Editor, click Skip Wizard. In the wpv-loop tags, type "YES" and in the wpv-no-items-found shortcode type "NO". The loop editor code will look like this:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>YES</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]NO[/wpv-no-items-found]
[wpv-layout-end]

- Place this View inside the loop of the View of Sports taxonomy just after the taxonomy title shortcode, and set the ids and terms attributes like this:

  [wpv-view name="Profile Term Glyph" ids="[wpv-post-id id='$current_page']" terms="[wpv-taxonomy-slug]"]

- This technique is called passing arguments to Views, and we have more information about it here: https://toolset.com/documentation/user-guides/passing-arguments-to-views/

Let me know if you are able to get this far, and then we can work on adding a glyphicon next.

#1212915

Hi Christian,

Great! I followed your very clear instructions and was able to obtain the expected results.

I'll wait for further instructions in order to display glyphicons instead of "YES" or "NO".

Thank you once again for your support.

#1213324

After the excellent support of Christian I just replaced the word "YES" and "NO" (respectively) in All Sports Terms View with something like this:

<span class="glyphicon glyphicon-ok-circle">
<span class="glyphicon glyphicon-remove-circle no_glyphicon">