Hello,
I can’t figure out why this loop isn’t working. Trying to query posts that are Tagged “Family”. Here is what I’ve tried…
<Loop type=taxonomy_term taxonomy=family orderby=title order=asc>
<h3><a href="{Field url}"><Field title /></a></h3>
<p><Field excerpt auto=true /></p>
</Loop>
Thanks,
Sammy
eliot
(Eliot Akira)
February 16, 2022, 3:59pm
2
Hi Sammy,
The loop type taxonomy_term
is for looping the terms of a given taxonomy. So, in the above code block, it’s trying to get terms from a taxonomy called family
.
To query posts, you can set the attribute type
to the post type you’d like to query, then use taxonomy
and terms
. The taxonomy name for tags is post_tag
.
<Loop type=post taxonomy=post_tag terms="family">
...
</Loop>
I hope that helps! I’ve made a note to clarify this difference better in the documentation.
I tried that and still no dice. I’m working with 2 different sites that have the same need and having issues with both.
<Loop type=post taxonomy=post_tag terms="family" orderby=title>
<h3><a href="{Field url}"><Field title /></a></h3>
<p><Field excerpt auto=true /></p>
</Loop>
<Loop type=espresso_events taxonomy=post_tag terms="frontpage_visibility" orderby=date order=desc count=1>
<h3><a href="{Field url}"><Format length=40><Field title /></Format>...</a></h3>
<p style="text-align: left;"><Field excerpt auto=true words=12 />...</p>
<p class="home-more"><a class="more-tag" href="{Field url}">Learn More</a></p>
</Loop>
eliot
(Eliot Akira)
February 21, 2022, 7:05am
4
Maybe the term name is not exactly the same as what exists. To confirm, could you run the following and check if family
exists in the list of terms?
All tags:
<ul>
<Loop taxonomy=post_tag>
<li><Field name /> (Posts: <Field count />)</li>
</Loop>
</ul>
Inside parentheses, it will show how many posts have that tag. So there should be at least one post associated with the family
tag.
(By the way, a code block in Discourse will display correctly if you add a line ```html
before it, and ```
after.)
Thanks for following up… I put your template into play on my dev space and works just fine… I see family is tagged on 22 posts.