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
- Prevent pre_get_posts filter on specific post type
- Search multiple custom fields by using meta_query
- Counting Posts of a Given Post Type Having a Specific Taxonomy?
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- 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?
- automatically create taxonomy with same name as post title
- Querying Posts by Taxonomy From Alternate Network Site
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- Multiple Archive Pages for Custom Post Types AND Taxonomies
- 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
- Best practice for adding posts in bulk
- Paginated Taxonomy Term Archive including one post per term
- WP 3.1 getting tax_query to work in query_posts()
- Querying CPT with Two Taxonomies
- Custom Query to display posts with custom field
- Get taxonomy description based on variable
- Impossible to get Attachments Outside WordPress?
- Is it possible to create a shortcode that will query a post based on taxonomies?
- wp_query to find posts by year and month
- Querying Term Posts in Loop
- Custom Post Type Loop within Shortcode
- Weird problem happening with custom taxonmy when creating/updating posts
- Filter by custom taxonomy slug on a custom post type
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- 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?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- Conditional Query of Custom Post Type and custom taxonomy
- How do I move/order posts with a tag to the end?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- Custom WP Query on custom meta and sort by multiple meta keys value
- Custom taxonomies relationship
- WP_Query custom post type query not showing the exact post type
- Query Custom Post Type Taxonomy term with multiple parameters
- Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
- WP_Query orderby and tax_query
- How to produce a sub-page-system in WordPress
- Retrieve custom post types by custom taxonomies with WP_Query
- Detect inside a custom query the kind of post type to assign custom classes
- WordPress wp_query() basic question about args
- Using page slug in wp_query
- Custom taxonomy wp_query woes.
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- how to get this tax_query working?
- Different options per post type in WP_Query
- 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
- Display Custom Post Types Glossary
- Exclude latest post from WP_Query taxonomy term loop
- How should I structure complex content hierarchies?
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Get terms for a specfic post from multiple taxonomies in custom post type
- 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
- Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?
- Display featured posts for a custom post type by taxonomy
- What is the most efficient way to execute recursive complex queries?
- How do I ensure that post_type and Taxonomy use the same slug?
- custom taxonomy pagination 404 error
- Ordering by meta value not working
- Custom Form / Search with Custom Post Type Data
- have to do a while have post to show for two custom post types sharing the same taxonomy?
- display post count in archive page that have relation with another taxonomy term
- How to search through all child taxonomies using WP_Query?
- WP_Query for custom taxonomies showing posts from non-specified terms?
- Query a custom taxonomy in a function to create an csv file
- CPT: multiple loops with different terms
- 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?
- Displaying WordPress posts from post and custom post type in custom taxonomy
- WordPress query posts by custom post type not workng
- Get posts of an specific term of a custom taxonomy
- Checking Taxonomy Terms for a Custom Post Type With get_the_terms Not Working
- Get posts associated with custom taxonomy alternate way
- Loop with Custom Post Type and Taxonomies
- How to query posts by meta keys AND under specific category?
- Shortcode display CPT Query only showing 1 post?
- tax_query showing no results
- Get link for feed of specific post type AND taxonomy
- How to display elements of different post types?
- Storing/querying custom date data
- Catergory args causing loop not to show
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- WP Query Conditionally query meta and taxonomy
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- WP Query – Can’t get posts with specific taxonomy