<?php
$categories = array('economy','the-constitution','monetary-policy','liberty');
foreach($categories as $category) {
$args = array(
'posts_per_page' => 1,
'category_name' => $category,
'tax_query' => array(
array(
'taxonomy' => 'highlight',
'field' => 'slug',
'terms' => array( 'lead','featured' ),
'operator' => 'NOT IN'
)
)
);
$wpse42358_query = new WP_Query( $args );
while( $wpse42358_query->have_posts() ) : $wpse42358_query->the_post();
// write post stuff here
wp_reset_postdata();
}
?>
I opted to use WP_Query because you have more control on taxonomy queries.
Related Posts:
- “tax_query” parameter not working with WP_Query
- Custom Taxonomy and Tax_Query
- Including all terms in wordpress tax_query
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- search query within custom taxonomy term, post title and meta field
- why do drafts return as part of wp_query?
- Hiding taxonomies with no children WP_Query & tax_query
- Set tax_query conditionally with new WP_Query
- How to do a particular wp_query taxonomy search
- WP_Query tax_query – Show results if child has parent X
- how to use tax_query to apply both terms or one if one is empty
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Advanced AND tax_query in sidebar with 2 taxonomies
- Using wp_query is it possible to orderby taxonomy?
- How do I exclude a custom taxonomy from the post loop
- WordPress tax_query “and” operator not functioning as desired
- Using WordPress to make a “Product Search” type navigation drilldown
- Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)
- display posts with same taxonomy term
- pre_get_posts with tax_query causes empty result
- The Operator “NOT IN” Does Not Work In tax_query
- How to get first post in a category of a custom taxonomy
- Display one post from each term in a custom taxonomy [closed]
- wp query with multiple taxonomy?
- wp_query orderby title and meta key value (WP3.1)
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- On Taxonomy Template page, want to add Post_Type
- Page queried instead of a custom taxonomy
- tax_query not working on main query
- Custom WP_Query breaks default behaviour of viewing right post associated with tax-term!
- The next_posts_link() show me a aditional page in blank
- Help with a query not working with custom taxonomy
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- Adding session variable and/or cookie based on user-selected input
- Ordering Posts with Custom Taxonomy Terms Array
- List taxonomy / category count showing list published posts only
- Excluding a custom taxonomy term breaks wp_get_post_terms
- Advanced Tax Query
- tax_query shows no results if nothing is selected
- Improving WP_Query performance for multiple taxonomies
- Dynamically tax_query terms
- How to output content based on same custom taxonomy?
- WP Query with custom taxonomy
- how to search in custom fields & custom taxonomy for custom search
- How do I sort posts by custom taxonomy?
- WP_Query, tax_query and term_meta: How to?
- pre_get_posts Tax Query not working for custom author page
- Get pages only with a specific taxonomy
- How to add autocomplete to custom taxonomy for CPT
- WP_Query on custom taxonomy works fine but fails if run through wp_ajax_
- Custom taxonomy query not working with switch_to_blog
- Advanced Query Logic With Multiple Taxonomies
- How do I Use Multiple Loops with WP_Query?
- cannot get multiple loops using tax_query
- ‘wp’ action hook not firing in admin and login?
- Taxonomy archive showing no results
- Get taxonomy parent using child slug (from merged taxonomies)
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Display all posts for taxonomy term across multiple custom post types
- Selecting all posts from the children of a particular parent taxonomy
- Manipulate WP Query using a custom post type and multiple tax_query taxonomies
- Retrieve Custom Taxonomies according to posts selected
- Custom Taxonomy Not Working When added to WordPress Search
- Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?
- How to display Related Posts based on number of taxonomy terms matched
- querying posts by custom taxonomy terms right from a querystring based URL
- tax_query not working in template
- Query custom taxonomy by term id?
- tax_query not working
- WP_query – Filter by tax_query and meta_query using multiple select
- When filtering query on custom taxonomy; main menu dissapears
- Exclude taxonomy term from all loops, but having it on widget
- Why can’t I use an array of term slugs in WP_Query?
- wp_query not resetting, last post hanging
- Using WP_Query and Query_post for the loop?
- WP_Query parameter conflict
- Problem with wordpress pagination
- Tax Query only returns for the first of several terms
- tax_query: Don’t show posts with parent term when they have a corresponding child term applied
- How to print term name inside wp post loop
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- tax_query (if the terms are empty)
- Create alphabetical Pagination for custom taxonomy?
- Custom arguments in WP_Query
- How to restrict search on a certain page to only return results against custom taxonomies?
- Wp_query…a type of term a different div
- check if a taxnomy queried in $wp_query?
- Taxonomy.php how to show post only in current taxonomy with wp_query?
- how to access the $query variable inside taxonomy-xxx.php template file?
- Query custom taxonomy for category including children
- Proper way to create taxonomy queries
- Get current page term title to use in WP_Query
- passing moree than one value of slugs in taxonomy using variable
- Get Posts Related to Category By category id or slug
- Display just the Post’s parent Category, not child
- custom post type and a “sticky” position taxonomy
- How to search through all child taxonomies using WP_Query?
- Tax-query on taxonomy doesn´t work
- how do you pull data from two taxonomies?