Skip Navigation

[Resolved] Output 0 for empty Taxonomy

This support ticket is created 6 years, 2 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Shane 6 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1145838

When displaying the output from a taxonomy list (whether from a custom search or not), is there a way to insert a '0' into the output array if the given taxonomy category is empty? I want to be able to manipulate the array content.

Ideally, I would prefer if the output was displayed as unordered list. Is this even possible?

Thanks

#1145938

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Michael,

Thank you for contacting our support forum.

Not sure if i'm following fully but is it that you want to output a 0 if a taxonomy listing is empty ?

Please let me know.

Thanks,
Shane

#1145949

Thank Shane

Yes, I would like it to output a 0.

And my second question would be how to output the list as an html list, rather than an array.

#1146002

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi MIchael,

Under which context you would like this to occur.

From what I know its not even possible to do this because you can either list out all the taxonomies or you can either list out all the posts and their taxonomies and finally you can list out all the Taxonomies and their posts under it.

The taxonomies that don't have any posts will not return anything.

So I need to understand the usage context.

Also for your second question is it a view ?

Thanks,
Shane

#1146013
ListLayout.png

I guess the best way to explain is with the attached rough example of how I plan to use the output.

If I need to add a little JS, that's not a problem.

#1146067

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Michael,

I see what you are trying to achieve.

I dont think this one is possible to acheive, especially in the table form that you want create.

The best way I can think of to get count of a term is to create a custom shortcode with the following function
https://codex.wordpress.org/Function_Reference/get_category

Thanks,
Shane