try with this function
function get_posts_in_taxonomy($post_type, $taxonomy, $term_id, $include_children=false, $limit)
{
$args = [
'post_type' => $post_type,
'posts_per_page' => $limit,
'tax_query' => [
[
'taxonomy' => $taxonomy,
'terms' => $term_id,
'include_children' => $include_children
],
],
// Rest of your arguments
];
$posts = new WP_Query( $args );
if($posts->have_posts()) {
while($posts->have_posts()) {
$posts->the_post();
//code todo here
}
}
} //end func
Related Posts:
- How do I exclude a custom taxonomy from the post loop
- Display category posts grouped by taxonomy
- display posts with same taxonomy term
- Including all terms in wordpress tax_query
- Display one post from each term in a custom taxonomy [closed]
- Is it possible to sort the post based on a custom field?
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Group posts that matches a term in a loop
- Custom taxonomy template loop
- How to handle “the_terms” inside loop
- Modify main loop in taxonomy archive page
- All posts are still shown when adding category argument to query
- Operations with custom fields values in a loop
- echo current taxonomy id for this loop?
- How do I Use Multiple Loops with WP_Query?
- How to adjust code to refresh a dropdown box with tags that are active on filtered category listing
- How can marge these loop code?
- How do I display a list of posts under all hierarchical children of the current taxonomy?
- Posts in loop displaying all taxonomies
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- where is the 4th taxonomy terms? taxonomy terms is disaapearing in the loop
- Display all posts that use a custom taxonomy
- If Custom Taxonomy
- How can I reduce amount of ifs and else ifs in this specific block of code?
- Returning One custom taxonomy term name
- Exclude taxonomy term from all loops, but having it on widget
- Using WP_Query and Query_post for the loop?
- Loop to display ONLY custom taxonomy parent information [closed]
- Loop through custom taxanomy in post and display custom fields from posts
- List terms of custom taxonomy if matches other taxonomy
- Only display latest custom taxonomy post
- how to get the post id in the option tag
- How to get the term description in a taxonomy term archive query?
- Chaining Taxonomy Queries
- Problem with sorting in custom child taxonomy archive page
- How to add a shortcode function that returns the taxonomy slug of the actual post within the loop
- Group posts in a category based on tags in custom taxonomy
- How to loop custom posts that have an exact match in taxonomy terms?
- Get post meta value outside of the loop
- ACF – Get unique values of array
- Remove Custom metabox from particular page template is used
- Custom taxonomy shows full articles
- Is it possible to sort the post based on a custom field?
- Output slugs to use as class names for every taxonomy a post is attached to
- Multi level archive
- List active taxonomy terms
- sort Posts by custom user filed
- How to get name of custom taxonomy
- Query pages by child term
- Query Number of Loaded Posts in Loop
- Trying to achieve row posts below category with multiple loops in custom tax
- Custom Taxonomy + JQuery Tabs
- WordPress show posts from children terms of a taxonomy term
- Loop custom post type by taxonomy (Category)
- How do I create a term for every value of a post meta?
- How home my code doesn’t display any feature image? Looping through post from a taxonomy and not getting feature images back
- Loop posts without any taxonomy
- How to looping taxonomy terms?
- Get the the top-level parent of a custom taxonomy term
- get_terms – only top level
- Custom taxonomy terms not showing as list Gutenberg Editor
- Order get_terms using a Custom Field
- Using pre_get_posts to rewrite search query to display posts from multiple taxonomies
- How to modify the query in taxonomy-custom.php to sort term archives by a custom meta field?
- wp_options table value
- Custom Taxonomy Meta Admin Column
- Custom Taxonomy Only Showing Top Level Terms in Admin?
- How to assign default taxonomy to pages on ‘save_post’?
- wp_query orderby title and meta key value (WP3.1)
- custom taxonomies on permalink
- Landing in 404 Page on Navigating to Custom Taxonomy Archive
- Get main term from a sub term in Woocommerce
- Generic taxonomy-term template page
- How to count the number of terms in a taxonomy
- Current category link filter
- Display only child terms of a specific parent term of a custom taxonomy, for each custom post
- Display Custom Taxonomy Alphabetically
- Are exclusive taxonomy terms possible?
- Some custom taxonomy child terms not showing in admin. Caching problem?
- Custom Taxonomy Query
- Pass taxanomy parameters to next_post_link()?
- Get all terms, including unchecked, or get the terms outside loop
- looping though custom post types and only return results in a given taxonomy
- My custom taxonomy page is leading in 404 page
- Show template part if part of term
- List Top 5 taxonomy terms based on number of post
- Taxonomy.php how to show post only in current taxonomy with wp_query?
- Include get_term_link inside search
- Shortcode to show the terms from the current post (custom post type & custom taxonomy)
- How to change Custom Permalink for Taxonomy? (remove the slashes from term-slug)
- How do I check to see if a specific child term has shared posts with another set of child terms within the same taxonomy?
- Custom Taxonomy Archive Page for Parents AND Children?
- Child Pages and Custom Taxonomies
- Display the first tag assigned to a post
- Sorting Custom Taxonomy in ASC/DESC order?
- Saving Taxonomies to Post Revisions
- Order posts by month – in custom taxonomy template
- Are taxonomy hierarchies possible?
- Error when adding custom taxonomy to wp nav menu
- Template hierarchy html with taxonomy in 6.2