How do I limit a query to a certain taxonomy?

I’m trying to build a loop that will grab posts only from a single category. After going through the documentation I’ve tried it several ways but keep getting the same result.

For the following example (pulled from page one of your documentation)

<ul>
  <Loop type=post count=3 orderby=date order=desc>
    <li>
      <a href="{Field url}"><Field title /></a>
    </li>
  </Loop>
</ul>

For the category term “hello” I’ve tried

<Loop type=post count=3 orderby=date order=desc id="hello">

and

<Loop type=post count=3 orderby=date order=desc include="hello">

What should I be doing instead?

Thanks!

1 Like

You can use taxonomy and terms to get posts from a certain taxonomy term.

<Loop type=post taxonomy=category terms="hello">

For a more detailed description, please see the list of query parameters from the documentation page Loop: Post, and search for the word “taxonomy”. There are some related parameters like taxonomy_compare and taxonomy_relation.


I was thinking it’d be nice to have a shortcut for querying by one or more categories (or tags), and it already exists: the category and tag parameters.

So the example can be simplified to:

<Loop type=post category="hello">
4 Likes