How to show category and subcategory name ??
-
How to show category and subcategory name for particular post category instead of showing all categories in the post ??
this is the short code am using
[a-z-listing taxonomy=”category” terms=”a-z-search” field=”slug” display=”terms” ]
The page I need help with: [log in to see the link]
-
I’m sorry, but I don’t think I fully understand the question and what you are trying to achieve. Can you try to explain the question in more detail please?
in this page https://identiti-portfolio.work/demo/coemwp/test-4/ and using the below shortcode. but in fact it shows all categories and subcategories which are here https://identiti-portfolio.work/demo/coemwp/wp-admin/edit-tags.php?taxonomy=category instead i just wanted to show only those categories or sub categories for this particular category “a-z-search” and which will be only these three ADHD, Anti-Aging & Autism . can you pls help me to achieve this ?
[a-z-listing taxonomy=”category” terms=”a-z-search” field=”slug” display=”terms” ]
appreciate any response on the above
You cannot filter a terms list. The best way to show a specific set of children terms is to put those terms into their own taxonomy.
—
In my experience most uses of parent->child terms are a result of putting multiple types of categorisation into a single taxonomy which is incorrect data architecture. For example, this is wrong: parent category called “videos” and child categories of “video type”; instead you should use a separate taxonomy called video-type, which is applied to a post-type called “videos”. The video-type taxonomy includes terms of each type of video, e.g. DVD, Blu Ray, Download..
For your example above you would create a new taxonomy called “A-Z Search” which includes each of the terms “ADHD”, “Anti-Aging”, “Autism”. Although creating a specific A-Z taxonomy is probably also the wrong way to go. You need to consider and implement a proper data architecture that categorises your posts. Your taxonomies should not create a cluster of terms specifically for the a-z-listing; nor should the taxonomies mash multiple types of taxonomy together. When you find yourself adding “child terms” consider whether it would be better to create a separate taxonomy (it usually is).
I’ve been looking over WordPress docs, and I think I can commit to including filtering in a future update, but for now it’s not possible ?? sorry.
You can now, in version 2.0.1, use a shortcode which takes the form:
[a-z-listing display="terms" taxonomy="post_cat" exclude-terms="5,9"]
Here I’ve told the plugin to display
Categories
excluding category ID 5 and category ID 9.exclude-terms
takes a list of term-IDs separated by commas:,
You can only use one of
terms
orexclude-terms
in the shortcode. You cannot use both in the same shortcode.You could also use
parent-term
:[a-z-listing display="terms" taxonomy="post_cat" parent-term="5"]
Is it possible now to show a category, i.e. brands, listed A-Z?
Yes, it is. The above suggestions should now all work correctly (once you correct for my mistyping of
post_cat
which should becategory
.)You used the word “category” suggesting that you are referencing a term in the taxonomy called “categories” but then named your term “brands” which is an aggregate name suggesting that it should be a taxonomy. I know that it’s confusing.
“Categories” is a “Taxonomy” and it contains “Terms” with each called “A Category”. Likewise “Tags” is another “Taxonomy” containing “Terms” each term being called “A Tag”.
My plugin can work with either the terms from a hierarchical subset of the “Categories” taxonomy, which I suspect is your situation, or it can show the terms from a complete taxonomy.
For a subset of the Categories taxonomy you want:
[a-z-listing display="terms" taxonomy="category" parent-term="42"]
The number in
parent-term
is a Term ID and must be replaced with the ID of the term (category) you named “Brands”, and all the terms (categories) you want in the A-Z listing need to be nested beneath Brands.For a complete taxonomy you want:
[a-z-listing display="terms" taxonomy="brands"]
The name
brands
needs to be the “slug” of the taxonomy containing the terms you want in the listing. I have provided a suggestion of “brands” which might be correct for your site but equally, it might not.Thanks for superfast answer! Unfortunately it still doesn’t work. The parent-term ID are number 12 and I’ve tried these codes:
[a-z-listing display=”terms” taxonomy=”category” parent-term=”12″]
[a-z-listing display=”terms” taxonomy=”varumarke” parent-term=”12″]This code kind of work, but it says “no-posts” when I inspect the source code. But there are many sub-categories, so what is missing here and why does it thinks it should be display posts?
[a-z-listing display=”terms” taxonomy=”varumarken” parent-term=”12″ grouping=”3″]
- This reply was modified 5 years, 10 months ago by caroline.
Hi,
The class name “no-posts” applied to the HTML source code is a historical artefact that I don’t want to change because it will break any CSS styles that people are currently using. It doesn’t mean anything beyond there being no items to display. The fact that it includes the word “posts” does not indicate that the plugin is trying to display posts instead of terms.
The taxonomy attribute needs to be the slug of the taxonomy. This is likely different from the name of the taxonomy. To find the slug, navigate to your administration screen and find the link “All brands” under the menu item on the left for one of your post-types e.g. posts (this is English, so you will likely see a translated version of this). Once you have found the link click it and then look in your web browser’s address bar. You should see an address similar to
https://example.com/wp-admin/edit-tags.php?taxonomy=brands&post_type=post
. Here the taxonomy name is “brands” so that is what I need to enter into the shortcode.
- The topic ‘How to show category and subcategory name ??’ is closed to new replies.