change your $args array to the following
$args = array(
'post_type' => 'product',
'posts_per_page' => 5,
'tax_query' => array(
array(
'taxonomy' => 'productcategories',
'terms' => $term->name,
'field' => 'name'
),
),
);
Related Posts:
- how to group custom post type posts by custom taxonomy terms
- How to get the parent’s taxonomy?
- Query for posts in 2 taxonomies
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Display custom post type from dynamic custom field
- Query/list all terms and their custom post count
- Archive for custom taxonomy lists all posts instead of current taxonomy
- How to display Related Posts based on number of taxonomy terms matched
- How to make WP_Query not to show irrelevant posts?
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- Sorting the Loop by Taxonomy Value
- custom post type and a “sticky” position taxonomy
- Use WP_query to match post types based on custom field values
- Values inside a custom field to determine which category posts to display
- Advanced search form with filters for custom taxonomies and custom fields
- Meta query with boolean true/false value
- Custom post type archive 404’s with paginate_links
- Counting Posts of a Given Post Type Having a Specific Taxonomy?
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- Displaying Posts Related to Other Posts by a Taxonomy Term?
- Querying Posts by Taxonomy From Alternate Network Site
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- Paginated Taxonomy Term Archive including one post per term
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- How can I display my custom metaboxes on a custom post template?
- Multiple post type queries (with specific arguments for each)
- Is it possible to create a shortcode that will query a post based on taxonomies?
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- wp_query to find posts by year and month
- Custom Post Type Loop within Shortcode
- Display CPT posts based on specific taxonomy
- Filtering WP_Query Dynamically on the Front-End
- Why get_posts() not returning only selected category posts from Custom Post Type?
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- How to use custom taxonomies to reference complex relationships?
- Get latest 3 posts from multiple CPT in one query
- Conditional Query of Custom Post Type and custom taxonomy
- Show a Category X’s custom post type on Category X archive page?
- How to duplicate entire custom post type
- Custom WP Query on custom meta and sort by multiple meta keys value
- Custom taxonomies relationship
- WordPress request fiter order by related post’s post_title
- How to edit this code to get the categories in achieve page?
- Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
- WP_Query orderby and tax_query
- Different Ways to Query Custom Post Types?
- Loop for custom post types filtered by a taxonomy
- WordPress wp_query() basic question about args
- Display different information of a custom post type
- How to get specific post meta by title or id
- how to show records that don’t have custom meta value
- how to get this tax_query working?
- find custom post type post by searching its custom field with my string
- FacetWP paging custom wp_query
- $post->post_meta not pulling any post in wordpress/php
- WP_Query of custom post type sorted by meta_key has unexpected results
- How to get the post terms from a child taxonomy
- display posts of custom post type with custom taxonomy
- Custom post type and custom taxonomy 404 on page 2
- Can’t change posts per page in WordPress Post Type Query
- WP_Query order custom post type with certain meta key value by post modified date
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Display featured posts for a custom post type by taxonomy
- What is the most efficient way to execute recursive complex queries?
- Find Posts based on Child Post value
- Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array
- set object terms after some some time of published post – functions.php
- Sort custom posts by date and then by taxonomy
- How to search through all child taxonomies using WP_Query?
- Posts per Page on custom Taxonomy Template
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How to get post by meta value
- How do I get all authors posts of a custom post type outside loop
- minimize wp_query call to database
- WP_query sort by taxonomy
- Getting Custom Posts with Custom Taxonomy
- Linking posts together with Advanced Custom Fields “both ways”
- Order posts by meta value hiding posts instead of re-ordering
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- How to get Current week and current date record wp query
- get_post_meta for Custom Post Type ( CPT )
- Checking Taxonomy Terms for a Custom Post Type With get_the_terms Not Working
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- WP_Query for CPT with filter by another WP_Query
- How to pass taxonomy terms to WP_Query along with $args?
- Display 2nd category, only once, as sub-heading, in the loop
- How to query posts by meta keys AND under specific category?
- Shortcode display CPT Query only showing 1 post?
- Storing/querying custom date data
- Query Posts From Multiple Post Types
- Return only custom post types for the page, not all
- send user to first page of results when reposting to page?
- Catergory args causing loop not to show
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- Display ACF object field data using Elementor Custom Query
- Assign a tag to custom post type using a query
- Sort ACF by custom taxonomy
- Complex Custom Loop with Includes
- Dynamically count the number of custom post types associated to a custom taxonomy