Taxonomy typically represent as an ‘array’ (even if you’ve only selected one term in the taxonomy), so you typically need to use the [each tax_name][/each] syntax for display in your Pods Templates.
So you’d do:
[each tax_name]
{@name} // it's name, not 'term'
{@slug}
{@permalink}
{@term_id}
{@custom_field}
[/each]
Does that help? If you wanted to output a list like get_the_term_list, you can do an unordered list and style it with CSS:
<ul class="genre-list">
[each genre]
<li><a href="{@permalink,esc_url}">{@name}</a></li>
[/each]
</ul>
Hi Jim!
Thank you for the really detailed answer! I feel like I was on the right track except for the {@name} magic tags that I didn’t know about. But it’s still not working and I don’t get why.
Here is what I did in one of my template where I call for a list of related users + a list terms from a custom taxonomy called “domaine”:
[if auteurs]
[each auteurs]
<span class="content-author">
<a href="/ergo-sum/{@user_login}/" alt="Profil de {@display_name}" title="Profil de {@display_name}"><span class="avatar avatar-55 photo">{@avatar.55}</span> <span class="author vcard">{@display_name}</span></a>
</span>
[/each]
[else]
<p>Nobody!</p>
[/if]
<ul class="domaine-list">
[each domaine]
<li><a href="{@permalink,esc_url}">{@name}</a></li>
[/each]
</ul>
My list of related users has been working since the beginning thanks to all the tutorials but I just can’t get the custom taxonomy to display like that… Do you see anything weird here?
Edit: without even thinking about a list, for testing purpose, what would be the shortest code to use in order to test if I can actually pull data from the custom taxo?
-
This reply was modified 2 years, 7 months ago by
Fred - FLQ.
-
This reply was modified 2 years, 7 months ago by
Fred - FLQ.
Well, your Taxonomy can’t be associated to the users. Is domaine
associated with this post type for this template?
Sorry, to your second question. I always test to see if the Taxonomy works by just going to the Taxonomy screen in WordPress back end admin, where the list of terms are, and the count of posts associated by that term and click “View”. If that doesn’t work, I know I’ve configured something incorrectly.
Hi Jim and thank you for the follow up.
Sorry about the confusion with users. My taxonomy is associated to the post type I’m trying to display it on (makes sense). I also already checked that when I click on “View” my CPT is displayed as part of my taxo archive page: so it seems perfectly associated.
I put the “users” template here because it’s a working one, on the same CPT (to which users are associated) and everything is working according to Pods’ documentation. That’s why I don’t understand why taxo is not showing up… I just checked again and the <ul>
is loaded perfectly, it’s just empty.
Since then, I have been able to display the taxonomy with Elementor dynamic fields (which also shows that the taxo is definitely connected to my CPT…). So I’m gonna use that as a workaround. Would love to understand what’s wrong though…
That’s typically when you have to verify spelling of your taxonomy name because that would be the only reason I can see why that wouldn’t work. I pretty much do the same thing you’re doing above all the time to create a similar output to get_the_term_list.
Check on your HTML output if it’s ‘iterating’ through the list items but not displaying anything, see if it’s creating the outer div.
Also just putting {@domaine}
will create a standard list of terms (when you provide an ‘array’ as a magic tag, it will output like “red, green and blue”), so you can use that to test it’s definitely recognizing your taxonomy at the post type level.
Hello
I also want to make a list in a custom template in pods
I made a Pods with Projects.
In the project i used some fields and a field with tags, also tags which you can find on the right site of that particular project ( as a default in posts of WordPress. For each project i give some tags, which i want to display as a list in that particular Project in the frontend.
How can make it a list in a template something
output such as ( Project A)
– tag 1
– tag 2
– tag 3
and for another Project page ( Project B)
– tag 3
– tag 6
– tag 999
Until now i only see for example in project A: tag 1, tag 2 and tag 3
Can you help me with making this work?
Thx in advance!
@qiem Please don’t jump onto the end of someone else’s support question, especially one that was closed over 5 months ago. Always create a new question so we don’t lose track of your question.
If you’re using the method we discussed in this video:
https://docs.pods.io/videos/grow-beyond-posts-pages-introduction-pods-framework/
You need to each through your post_tag
taxonomy (which is what ‘Tags’ is called inside WordPress). If you want it to be available to Pods, you need to go into the Pods Admin, Add New, Extend Existing, choose Taxonomy and then Tags in order to ‘extend’ post_tag
so it’s available to Pods Templates. We discuss using an each tag for Taxonomy in this document:
https://docs.pods.io/displaying-pods/template-tags/each-loop-tag/