[total_taxonomy]
Shortcode displays total taxonomy terms count on your site.
Attributes
- taxonomy
- (required) Taxonomy name. E.g.:
product_tag
.- Default: None
- parent
- (optional) Parent taxonomy term ID. Enter zero to count top level terms. Enter
current
to set to the current term ID. Leave empty to count all terms.- Default: None
- hide_empty
- (optional) Set to
yes
if you want to skip empty terms.- Default:
no
- Default:
Examples
Example
[total_taxonomy before="Total product categories: " taxonomy="product_cat" on_zero="No product categories."]
Output
No product categories.
Hello,
i don’t understand how to show total_taxonomy for each parent category whithout all categories in my website. Even with exemple with just texts, i don’t understand how to modify the code. Can you help me please ? For this code:
Thanks ! 🙂
Hi, Thomas,
Please update the plugin to the latest v1.7.1 (released today) – now you can set the
parent
attribute tocurrent
, e.g.:Please give it a try and let me know what you think.
Hello, thank you very much for the update!
I still don’t understand where I can enter the parent category ID in this code? The place where I put the cide, detect automatically the parent ID category ?
Thanks for help! 🙂
Hi, Thomas,
Yes, it will automatically detect the current category and replace the
current
placeholder with an actual product category ID.I’ve tested it by adding the shortcode to a sidebar widget, and it seems to be working fine – the value automatically changes depending on which product category the user is viewing.
Hello, it’s weird because it doesn’t detect the category on the page where the code is.
For example, on my site for “Suzuki Recalls”, it doesn’t detect the category.
https://carnews-france.fr/rappels-alpine/
Can I log in and take a look (my email is tom@anbinder.me)?
Yeah,
you can register
Hi, Thomas,
I’ve just registered, but I would need a higher user role to see the admin settings.
Hello,
Hello, okay, you are now admin,
I test in this page https://carnews-france.fr/rappels-alpine for your shortcode.
Hi, Thomas,
I’ve checked the site, and now I’m not sure if I understood the task correctly in the first place.
Few notes:
It looks like you don’t have the
product_cat
taxonomy on your site (usually this taxonomy comes from the WooCommerce plugin). In your case, I think you need to use thecategory
instead, e.g.:Also, you are using the shortcode on a WordPress page, so we can’t automatically detect the current category, i.e., we can’t use the
current
placeholder I added recently. Instead, you would need to set the category ID directly, for example, for the “Rappels : Alpine” category on your site:* However, it will still display “No categories” as it looks like the “Rappels : Alpine” category doesn’t have any subcategories.
To use the
current
placeholder, you have to add the shortcode to the category view, e.g., https://carnews-france.fr/category/rappels-alpine/I hope this helps, and please let me know what you think.
Hello,
thank you for your feedback,
in fact, I’m not looking for a sub-category for Rappels: Alpine, for example. I just wanted to have the total number of items in this main category, because each time I add an item, having previously checked the category of the item in question, I have to manually increment +1, nothing is automatic.
Hi, Thomas,
Ok, in this case, I think you need the
[total_posts]
shortcode. However, currently, it doesn’t have an option to select categories. Let me add it to the plugin and get back to you.Hello,
Allright, thanks a lot !
Hi, Thomas,
Sorry for not getting back to you sooner.
Please update the plugin to the latest v1.7.2 – now you can set category ID in the
[total_posts]
shortcode with thecategories
attribute, e.g.:If you are displaying the shortcode on a category archive page, you can use
current
:Also, you can set multiple categories with a comma-separated list:
Please give it a try and let me know what you think.
Hello,
It works perfectly, thank you very much!!!
Happy to hear it’s solved 🙂 Let me know if you need anything else.
P.S. If you like the plugin, please consider leaving me a rating.