The problem is with your tax_query
— the field
(database column name) does not match the terms
(database column values):
$args = array(
...
'tax_query' => array(
array(
'taxonomy' => 'state',
'field' => 'name', // <- this should be set to 'slug'
'terms' => $state_slug, // because you provided term slug
),
),
);
I.e. If you provide term slugs (e.g. foo-bar
), then the field
should be slug
; if you provide term names (e.g. Foo Bar
), then the field
should be name
.
Related Posts:
- Display all posts in a custom post type, grouped by a custom taxonomy
- Getting custom taxonomy from custom post type
- WordPress Search documentation: how to improve search query using taxonomy terms, custom meta fields?
- Order custom posts by taxonomy?
- Retrieve a specific field from taxonomy term through advanced custom fields [closed]
- List events by month
- Conditional two level dropdown filter for custom post type
- Show all custom post type posts sorted by custom taxonomy then by another custom taxonomy
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Taxonomy posts on Archive page
- Randomly placed sticky custom posts complemented by blog posts
- get terms that have post with custom post type between 2 values
- How to display the rest of categories on Portfolio filterable
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Loop and add Specific Categories and Products Images
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- How do i display post from a taxonomy term?
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- What is the most efficient way to execute recursive complex queries?
- How can I loop at a Specific Taxonomy from a custom post type?
- Fetch data from two custom post types and create multidimensional array for output to html table
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- ACF – Retrieve custom taxonomy from a relationship field
- Custom archive page for custom taxonomy and pagination issue
- How to display list of custom post taxonomy terms and their posts (if any)?
- Custom front-end form for adding post – Category problem
- Create loop from selected terms in ACF taxonomy field
- Sort custom posts by date and then by taxonomy
- Custom post type paging return home page
- Is it possible to add the Gutenberg block editor to a custom taxonomy?
- How to debug failing updates for custom post type?
- Excluded Custom Taxonomy Term Posts Displaying in loop
- Show custom post type event if current day using ACF
- Display Custom Field or Custom Taxonomy in front page /post/product
- WP_Query not using custom taxonomy categories on custom post type
- If ACF Post Object post has custom taxonomy term…
- Combine multiple separate lists into one
- ACF meta_key and meta_value break loop
- Taxonomy shows up twice on Custom Post Type
- How to display custom post type pagination buttons when processing AJAX request
- posts_per_page is not working by term
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- Multiple Custom Post Type in Taxonomy Archive Causing White Screen
- Adding a Section for Visitors
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- Show parent category and subcategory once in while loop
- List all posts associated under custom taxonomy
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- Display custom tax in “while” loop
- % encoded URL giving 404 error in WordPress
- CPT: multiple loops with different terms
- Display title of all custom posts from same taxonomy term on a custom post template
- Loop to display parent categories in custom taxonomy
- Custom taxonomy template for custom fields loop [closed]
- Add active class to foundation 6 tabs while looping categories
- How to show terms used only for particular custom post type. Filter creation perpose
- Display related post content and custom field content
- Best way to have one product in both rental and sale parent category
- Show posts for current taxonomy
- Custom post types not displaying per category
- Looping through custom taxonomy in one template
- WordPress query posts by custom post type not workng
- Custom post type with custom taxonomy permalinks
- Custom taxonomy page template
- Loop with Custom Post Type and Taxonomies
- How to query posts by meta keys AND under specific category?
- Loop multiple taxonomy in custom post
- $post breaking container loop
- Post data in separate divs with incrementing class using WP_Query
- WordPress Custom Post Type and sort by Tags
- Display posts from category in page
- Order by custom field attribute
- Display Custom Taxonomy of custom post type
- How to query the content of a specific custom post type?
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Advanced Custom Fields: query posts filtered by multiple field values
- Sorting custom post types by taxonomy (So close)
- Looping taxonomy in taxonomy?
- Listing custom post type items from a couple of custom taxonomies
- Loop through multiple custom taxonomy terms and display posts for a custom post type
- Custom Post Type Loop breaking php
- Styling first post using Advanced Custom Fields
- Catergory args causing loop not to show
- display custom post type from register taxonomy
- ACF Relationship: Group posts by parent category term, then child [closed]
- Get all active posts that are tied to a custom taxonomy for a custom post type
- Filter page ID outside the loop and order
- Custom taxonomy meta fields
- Custom Sort Order for Custom Post Type Taxonomy
- Complex Custom Loop with Includes
- Create a WordPress loop that shows posts from a custom post type + filters the posts by taxonomies while hiding empty taxonomies
- WordPress post objects in one parent post object
- Add Custom Taxonomy Terms as CSS Classes for CPT Posts in an Elementor Loop Item Template
- ACF Pro simple Business Directory – Requesting assistance with created Templates and associated Functions.php Coding
- Custom fields disappearing when a custom post type is assigned
- Post term block variations not generated for custom taxonomies
- How to Filter the Custom term loop based on dropdown
- How to Dynamically Filter Custom Post Types by Taxonomy Based on URL in Elementor Pro and ACF?