Skip Navigation

[Resolved] Taxonomy description not displayed when there are no posts in taxonomy

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

Problem:
How to show Taxonomy description even if there are no results or no posts for that taxonomy?

Solution:
Use this shortcode in the WordPress Archive View:

[wpv-taxonomy-archive info="description"]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-archive

This support ticket is created 6 years, 9 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
- 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 6 replies, has 2 voices.

Last updated by guyA-2 6 years, 8 months ago.

Assisted by: Noman.

Author
Posts
#551953

I am trying to: Display taxonomy description even if there are no results for in the taxonomy:
hidden link
Take a look at our Certified Therapist Training Taxonomy in the sidebar.
It has 5 levels. Level 2, 4 and 5 have posts assigned to them. But levels 1 and 3 have no posts assigned to them. But even if there are no posts in a level we still want the description to display. Then a message saying there are currently no trainings for this level.

At the moment I've using this:

[wpv-no-items-found]
<p>[wpv-post-taxonomy type="certified-therapist-training" format="description"]</p>
<p>[wpml-string context="wpv-views"]We have no upcoming trainings at the moment. <a href="/email-sign-up" title="Sign up to our email list to stay in the loop">Join our community</a> and we'll keep you in the loop about future training courses and workshops.[/wpml-string]</p>
[/wpv-no-items-found]

But this appears outside the WordPress loop so I can't use the taxonomy description in this block.

I've tried removing this block and using a conditional tag within the content template:

I've tried adding a conditional in the content template to display different content.
[wpv-conditional if="( '[wpv-items-count]' gt '0' )"]

to display the posts and

[wpv-conditional if="( '[wpv-items-count]' lt '1' )"]

to display a different message when there are no items.

But this doesn't work. I've also tried using [wpv-found-count] as a conditional but this doesn't seem to work either.

Is it possible to have a taxonomy description displaying even if there are no results for this description?

Thanks for your support.

#551987

Noman
Supporter

Languages: English (English )

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

show empty terms.png

Hi,

Thank you for contacting Toolset support. For this should need to add shortcode and text within [wpv-no-items-found] shortcode, replacing the text “No items found” -- first check it by only replacing this text to see if it works in your site and later add the shortcodes.

1. Please Edit View >> in Query Options >> Please disable this option “Don't show empty terms” -- screenshot attached.

2. Please use this shortcode for Taxonomy Description:

 [wpv-taxonomy-description] 

Thank you

#552193

Hey Noman,

This is in a taxonomy archive page and not a view.
On this page you see the taxonomy description displaying because there are results:
hidden link

But on this page there are no results being displayed:
hidden link

Here's the code that I have in my WordPress archive loop:

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>

[wpv-post-body view_template="Content template for Certified Therapist Trainings"]

</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]

[wpv-no-items-found]
<p>[wpv-taxonomy-description]</p> //This is the description that is not showing up
<p>[wpml-string context="wpv-views"]We have no upcoming trainings at the moment. <a href="/email-sign-up" title="Sign up to our email list to stay in the loop">Join our community</a> and we'll keep you in the loop about future training courses and workshops.[/wpml-string]</p>
[/wpv-no-items-found]

[wpv-layout-end]

Thanks for your support!

#552214

Noman
Supporter

Languages: English (English )

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

hidden link
-- Is this the Archive View you are using for the Level 1, Level 2 taxonomy pages or its some other Archive View you are talking about?

Archive View ID = 2571

#552234

No this is the view being used for this page:
hidden link

#552260

Noman
Supporter

Languages: English (English )

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

I have replaced the shortcode with [wpv-taxonomy-archive info="description"]:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-archive

And now its working good for Empty Taxonomy Terms as well:
hidden link
hidden link

The updated code in the View Loop is:

[wpv-no-items-found]
		<p>[wpv-taxonomy-archive info="description"]</p>
		<p>[wpml-string context="wpv-views"]We have no upcoming trainings at the moment. <a href="/email-sign-up" title="Sign up to our email list to stay in the loop">Join our community</a> and we'll keep you in the loop about future training courses and workshops.[/wpml-string]</p>
	[/wpv-no-items-found]

I hope its all good now, please let me know. Thank you

#552850

Great support. Thanks for your help.

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