Assuming that you are on a taxonomy or term page then you can simply use:
//get current term
$term_slug = get_query_var( 'term' );
//get current taxonomy
$taxonomyName = get_query_var( 'taxonomy' );
$loop = new WP_Query( array(
'post_type' => 'work',
'posts_per_page' => 10,
'orderby' => 'ASC',
$taxonomyName => $term_slug);
while ( $loop->have_posts() ) : $loop->the_post();
Related Posts:
- Custom Taxonomy with Custom Post Type Finds No Posts
- WP_Query for CPT with filter by another WP_Query
- Display all posts in a custom post type, grouped by a custom taxonomy
- How do I append multiple taxonomies to the URL?
- Prevent pre_get_posts filter on specific post type
- Exclude a category from WP_Query
- $wp_query->queried_object->ID throws warning: Undefined property
- Search multiple custom fields by using meta_query
- Select All in Parent Category, Group by Child Category?
- get_query_var() not working in pre_get_posts
- query multiple taxonomies
- The Operator “NOT IN” Does Not Work In tax_query
- Get custom post type by category in a page template
- Associating an “author” with a custom taxonomy
- Counting Posts of a Given Post Type Having a Specific Taxonomy?
- Custom query – alternate posts by category
- TV Show database – Best way for structuring it?
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- How to get_queried_object on multiple objects?
- Correct way to use a form to to filter custom posts by taxonomy terms?
- how to group custom post type posts by custom taxonomy terms
- Showing current taxonomy terms
- Displaying Posts Related to Other Posts by a Taxonomy Term?
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- How to get the parent’s taxonomy?
- automatically create taxonomy with same name as post title
- Querying Posts by Taxonomy From Alternate Network Site
- Query posts by custom post type and custom taxonomy
- Sort the main query in subcategories/terms?
- Custom Taxonomy conditionals
- Help with hierarchical custom taxonomies and permalinks…almost there
- Custom Taxonomy List links being re-written
- custom post type paging not working past page 3
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- Want to filter only parent post in admin area
- Multiple Archive Pages for Custom Post Types AND Taxonomies
- Custom Taxonomy and tax_query Issue?
- Query for posts in 2 taxonomies
- Exclude current post when getting related post on custom post type and taxonomy
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Ordering Custom Post Types with WP_Query
- After deleting a post are terms, and custom meta deleted?
- Best practice for adding posts in bulk
- Paginated Taxonomy Term Archive including one post per term
- Custom post query by taxonomy
- WP 3.1 getting tax_query to work in query_posts()
- Querying CPT with Two Taxonomies
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Custom Query to display posts with custom field
- Get taxonomy description based on variable
- Impossible to get Attachments Outside WordPress?
- Programmatically adding posts
- Keep main articles and author blogs seprerate, News / Magazine like site
- Optimised Code for Pulling Taxonomy Posts
- Why is my custom loop not filtering correctly nor paginating?
- Custom post types with custom directories
- Show Post Count of a Category
- WP_Query search posts by custom post type and custom taxonomy
- removing custom tax & CPT slug, adding taxonomy term in front of custom type
- How to customize admin posts based on the user who is logged in
- Is it possible to create a shortcode that will query a post based on taxonomies?
- Show Two custom Post type and their posts on category page
- wp_query to find posts by year and month
- How to create an advanced filter search?
- Query a custom taxonomy in a function to create an csv file
- WP_Query based on ‘s’ and tax_queries
- Building Link List for Custom Tax
- WP_query sort by taxonomy
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Ajax load more inside custom post type taxonomy
- CPT: multiple loops with different terms
- WP Query tax_query not returning posts
- Create a custom wp_query from a specific custom post type with specific taxonomy
- Multiple WordPress Sites, Same Database but Filtered Content
- The most recent post of custom taxonomy
- Help with Travel Guide Setup
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Problems with the WP_Query query for a Custom post type
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Display all Custom taxonomy terms and their relevant custom posts
- WordPress query posts by custom post type not workng
- Get posts of an specific term of a custom taxonomy
- Query pulling all taxonomies, not one I am specifying
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Checking Taxonomy Terms for a Custom Post Type With get_the_terms Not Working
- CPT Efficient way to display posts from different categories with custom query
- Get archive of posts separated by taxonomies and subtaxonomies
- Query Pulling the same post twice
- Custom post type and custom taxonomies display
- Get posts associated with custom taxonomy alternate way
- How to pass taxonomy terms to WP_Query along with $args?
- WordPress custom post type
- Loop with Custom Post Type and Taxonomies
- Custom Taxonomy Query by Taxonomny not working
- How to query posts by meta keys AND under specific category?
- Shortcode display CPT Query only showing 1 post?
- tax_query showing no results
- Post data in separate divs with incrementing class using WP_Query
- Values inside a custom field to determine which category posts to display