Try 'category_name' => $category->slug
instead of 'category_name' => $cat_name
.
You are also missing wp_reset_postdata();
just after endwhile;
.
Related Posts:
- WP_Query by a category id and a custom post_type
- Exclude a category from WP_Query
- WP_Query ignores post_type in category view
- category__in not working on custom post type
- List with categories, subcategories and posts of custom posttype
- New WP_query in template not working with CPT+category on some pages
- WP Query group/order by category name
- List all custom post type posts from a given category?
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- WP_Query with custom post_type and cat retrieving unwanted posts with the custom posts
- Query Custom Post by Category
- Getting all custom posts with a certain category
- Query Custom Post Types & category_name?
- Show Post Count of a Category
- CPT posts listed by category with custom rewrite URL, please help!
- Querying Term Posts in Loop
- Pagination on category page with custom post types
- How to show CPTs in term archive
- showing custom post types of a certain category only
- Linking to the most recent post in a Custom Post Type
- Show custom post type filtered by category
- forming WP_Query for posts of all post types but from specific categories
- WP Query with categories only shows one post and ignores the category
- Why is my category template ignoring post type?
- WP the_posts() on single-cars.php get category link
- WP_Query Custom Post Type if Category ID Equals
- Custom post types and ‘new WP_Query’
- How to include category name/id in wp_query for retrieving “custom post type” from a particular category?
- List categories, subcategories and posts from custom taxonomy and custom post type
- WP Query results showing posts outside of category ID
- How to get Custom Post Type with Categories wise in WordPress using wp_query
- Create query for both custom post type and category
- How to properly use Categories with Custom Post Types
- How to output custom post type title on custom page with category next to it?
- Custom Post By Category
- Only show categories that have posts within custom post type
- Query the title of the page to show posts with matching category in the loop
- Only show current category post
- Can’t seem to filter wp_query by current category ID
- Custom Post Type + Category archive
- category_name not working in WP_Query
- Get all custom_post_type posts + blog posts from one category in a single query
- Using tax_query to get single post per category
- Are custom posts included when getting a categories’ posts?
- Is it possible to make is_category() recursive?
- Query by post title
- Get category id from post id of a custom post type
- Number of pages – multiple (custom) post types
- Get latest 4 post on a custom post filtered by category
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- wp_query and comment_parent – select only posts with top level comments
- Comparing timestamps in meta query doesn’t work
- Include both default and Custom Post Type in query modified inside pre_get_posts
- Taxonomy structure of Sport site
- Sort by two dates. Default entry date and custom field if present
- Querying CPT with Two Taxonomies
- Return array of categories to php function for current post
- Custom Post Types not showing, custom WP_Query
- Pagination is not working on single-{slug}.php but works fine on page-{slug}.php
- Sorting multiple custom post types without a meta key/value pair by sort order
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- wp_query check if integer exists in custom field’s array
- Previous/Next Link by Meta Value in CPT
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- WordPress posts page for customer filtering and sorting along with category filter
- List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
- Why is my WP Query not returning first result’s post meta?
- Showing custom post type categories in the menu
- Creating Sections for Post Types
- Select2 AJAX and WP Query Returns ALL and does not filter
- WP_Query orderby not work with meta_key
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Returning a custom content types with meta values
- Searching post types
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- wp_query not returning my custom post
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Displaying taxonomies as category links within sidebar and creating pages for these
- Get next and prev item from custom WP_Query and Custom Post Type
- Query to show post current day
- Using ACF values in nested WP queries for CPT with date values in the past
- WP_Query: how to search tags in addition to a custom post type?
- Pagination Not Working When Used With WP_Query() `offset` Property
- Help understand and create a loop with WP_query
- WP_Query for custom taxonomies showing posts from non-specified terms?
- Make pagination work as a carousel (custom query)
- WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category
- Search result based on URL
- Adding categories to custom post type in permalink
- How can I generate a list of post-type specific categories?
- New WP_Query not isolating custom post types on front-page template
- Get a list of categories ids
- category page template for custom post type
- Pagination not working on homepage
- How to query custom post then display sections by meta value
- Return Custom Post Type Categories
- Show Posts in Vertical Tabs with Scrollbar
- What Is My Fault With This WP_QUERY ? [ Pagination Problem ]
- Default WordPress Query for a Specific Custom Post Type URL
- Dynamically count the number of custom post types associated to a custom taxonomy