Firs of all don’t use query_posts()
ever, read more about it here: When should you use WP_Query vs query_posts() vs get_posts()?.
You have to use WP_Query
to fetch posts what you need. Read documentation for it. In your case the query could be like this:
$the_query = new WP_Query( array(
'post_type' => 'Adverts',
'tax_query' => array(
array (
'taxonomy' => 'advert_tag',
'field' => 'slug',
'terms' => 'politics',
)
),
) );
while ( $the_query->have_posts() ) :
$the_query->the_post();
// Show Posts ...
endwhile;
/* Restore original Post Data
* NB: Because we are using new WP_Query we aren't stomping on the
* original $wp_query and it does not need to be reset.
*/
wp_reset_postdata();
Related Posts:
- how to group custom post type posts by custom taxonomy terms
- Posts per Page on custom Taxonomy Template
- How to get the parent’s taxonomy?
- Query posts by custom post type and custom taxonomy
- How to get only one category of custom post type?
- pre get posts changing the query
- Query for posts in 2 taxonomies
- ‘category__and’ for custom taxonomy?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- List custom post type by custom tax term as page title
- how can i get posts from custom post type particular taxonomy category
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- Query/list all terms and their custom post count
- Archive for custom taxonomy lists all posts instead of current taxonomy
- How to use custom taxonomies to reference complex relationships?
- Query Custom posts of same taxonomy as the post itself
- Conditional Query of Custom Post Type and custom taxonomy
- Show a Category X’s custom post type on Category X archive page?
- How to edit this code to get the categories in achieve page?
- Listing all term items alphabetically / sorting loop
- How to display Related Posts based on number of taxonomy terms matched
- How to make WP_Query not to show irrelevant posts?
- Custom query – get_the_terms not work
- Control content before and after custom post type loop
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- Display custom posts randomly in custom taxonomy archive
- Not able to export large no. of posts in csv
- attach CPT data to a taxonomy
- Targeting custom post type via functions.php doesn’t work
- List all posts in taxonomy term
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Sorting the Loop by Taxonomy Value
- custom post type and a “sticky” position taxonomy
- Posts per Page on custom Taxonomy Template
- Getting Custom Posts with Custom Taxonomy
- WordPress custom post type
- Display 2nd category, only once, as sub-heading, in the loop
- Advanced Custom Fields: query posts filtered by multiple field values
- Inserting two categories
- get_the_category_list or get_the_tag_list for custom post types and taxonomies?
- wp_get_object_terms(): count relative to passed IDs?
- Add/overwrite a parameter on an existing post type/taxonomy
- Get the ‘slug’ of a custom taxonomy
- Custom Metabox with Taxonomy Dropdown – Saving Issue
- Custom Post Type / Taxonomy Slug / Post Title with post type archive
- Term Checklist Walker – Disable Parent Categories
- Show certain terms from custom taxonomy but exclude ‘parent’ terms?
- Limiting number of custom posts shown on taxonomy page
- Custom Taxonomy conditionals
- How to create archive page for taxonomy terms within custom post type
- How do I provide a “show all posts” link in a paginated term archive?
- List terms from Custom Taxonomy
- Set object terms not working on plugin activation
- custom taxonomy relationship
- Parent & Child Taxonomy slugs in custom post permalink
- How to use the post_title of custom post type as taxonomy
- Custom Post Type Archive Page Filtering
- Custom Post Type With Categories
- Missing Posts in Custom Taxonomy List
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Permalinks /country/city/cpt/postname/
- Seamless permalinks between Custom Taxonomy and Custom Posts
- browse by category and tags?
- Taxonomy structure help
- Create more category hierarchical depth for custom post type/taxonomy plugin (widget)
- Show custom post type inside a custom post type
- How to check if post/page or taxonomy post is published by admin
- Custom taxonomy or custom page templates?
- Get terms of a post but only if they’re also the child of a specific term
- Custom Post Type Advanced Slug
- Get posts by category name
- How to implement very unusual wordpress routing structure?
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Changing permalink of default Post with custom post
- get_queried_object not work in taxonomy page
- Change custom post taxonomy values from front-end
- Pages of my taxonomy terms are showing all posts
- Is there a way to re-order the Custom Taxonomy drop-down on a Custom Post listing page?
- How to get all posts related to a taxonomy?
- Custom post types not displaying per category
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- predefined custom field on registration page
- Displaying taxonomy icon outside archive page
- Why won’t this rewrite rule work?
- Archive.php is not displaying tags
- How to not have the items of the subtaxonomy within the parent taxonomy
- How to save an integer as taxonomy term?
- Tags and Taxonomy links not working for Custom Post Types
- How can i change url structure of cpt like this?
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- the_post_navigation in single page with multiple taxonomies
- Url rewrite with custom post type and taxonomy
- Custom taxonomy meta fields
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- Problem with shortcode
- Custom Sort Order for Custom Post Type Taxonomy
- How to add categories to a custom post type using wp_insert_post($new_post);
- Modify permalink of CPT archive to support two taxonomies
- WP Query – Can’t get posts with specific taxonomy