Learn the difference between free and premium WordPress themes. Find out which one is right for your website with pros, cons, and tips.
How to Display Posts by Taxonomy and Term in WordPress

Table of Contents
- What Is a Taxonomy in WordPress?
- Why Display Posts by Taxonomy and Term?
- How to Display Posts by Taxonomy and Term (Code Example)
- Display Posts Without Code (Plugin Option)
- Related Blog Posts
- FAQs
Are you using custom taxonomies or categories in WordPress and want to show specific posts based on a term like a “Brand” or “Product Category”?
This tutorial will show you how to do that using WordPress functions with clean code, and also a no-code method using plugins.
What Is a Taxonomy in WordPress?
In WordPress, a taxonomy is a way to group content. You’re probably already using built-in taxonomies like:
category
post_tag
But WordPress also allows you to create custom taxonomies like:
brand
genre
location
Each taxonomy has terms, such as Samsung
(term) in brand
(taxonomy).
Why Display Posts by Taxonomy and Term?
You may want to:
- Show posts under a specific category or tag
- Display products by brand in WooCommerce
- Filter content by custom post types and custom taxonomies
This helps organize your website, improve navigation, and enhance user experience and SEO.
Step-by-Step Guide to Display Posts by Taxonomy and Term
To do this, we use a WordPress class called WP_Query
, which allows custom database queries.
You’ll need to know:
- Your post type (e.g.,
post
,product
) - The taxonomy name (e.g.,
category
,brand
) - The term (e.g.,
electronics
,samsung
)
Code Example Using WP_Query
Here’s the code to display posts by taxonomy and term:
<?php
$args = array(
'post_type' => 'product', // Change to your post type
'tax_query' => array(
array(
'taxonomy' => 'brand', // Your taxonomy
'field' => 'slug', // Use 'term_id' if you prefer ID
'terms' => 'samsung', // Replace with your term
),
),
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<div><?php the_excerpt(); ?></div>
<?php endwhile;
wp_reset_postdata();
else :
echo 'No posts found.';
endif;
?>
Make sure to replace:
'product'
with your post type'brand'
with your taxonomy name'samsung'
with your term slug
Note: Add this code in a template file, inside a shortcode, or in a custom block.
Use a Plugin Instead (No Code Option)
If you’re not comfortable adding custom code to your theme files, there are several WordPress plugins that let you display posts by taxonomy and term without any coding. Here are some popular options:
- Custom Post Type UI – This free plugin allows you to easily create and manage custom post types and taxonomies. It’s user-friendly and widely used by developers and beginners alike.
- Content Views – A great plugin that lets you filter and display posts by taxonomy using a visual drag-and-drop interface. Ideal for those who want full control without touching code.
- FacetWP (Premium) – Perfect for advanced filtering needs. It supports WooCommerce, custom post types, and offers fast AJAX filtering. A powerful tool for large content-heavy sites.
These plugins make it simple to organize and show content based on taxonomy and term, all without writing a single line of code.
Related Blog Posts
Want to dive deeper into custom taxonomies and WordPress development? Check out these helpful tutorials:
How to Create and Display a Custom Brand Taxonomy in WooCommerce
How to Add Custom Post Types and Taxonomies in WordPress
These guides explain how to register and use custom taxonomies, especially useful if you’re building advanced WordPress websites.
FAQs
Can I use this code for blog posts?
Yes. Just change 'post_type' => 'post'
and 'taxonomy' => 'category'
.
Will this work with WooCommerce?
Yes. Use 'post_type' => 'product'
and taxonomy like 'product_cat'
or 'brand'
.
Can I show posts by multiple terms?
Yes. Use 'terms' => array('term1', 'term2')
.
Where do I place this code?
Add it in a page template, shortcode, or widget using a custom plugin.
What is the term slug?
It’s a URL-friendly version of your term name (e.g., samsung
instead of Samsung
).
This Post Has 0 Comments