Filtering posts by using multiple tags

WordPress allows you to filter posts by multiple tags at the time. You can use the AND (+) and OR (,) operators to do this. To make this work you need to make sure that you’ve set up your templates properly and that you’re using the taxonomy.php to display build-in posts or the taxonomy-[post-type].php template if you want to do this for your own custom post type.

Imagine we have a custom post type called book and we have set up a none hierarchical taxonomy (tags) called “Genre” for this post type. If we want to display all books that are tagged Science Fiction and Thriller we can use the following URL:

The above let’s WordPress query for all books that are tagged with both Science Fiction AND Thriller. If we want to broaden our filter we can use the OR operator instead:,thriller

This query let’s WordPress find all books that are tagged with either Science Fiction or Thriller. It should return a larger result set.

Bon App├ętit!

Tagged with: