Unless you have posts that don’t have a city aren’t you essentially querying all your posts? Anyway, Eric Holmes is correct that you should be using WP_Query
in lieu of query_posts()
.
That said, you can get a list of all the terms in a taxonomy and then use those values in your tax query.
// get all terms in the taxonomy
$terms = get_terms( 'city' );
// convert array of term objects to array of term IDs
$term_ids = wp_list_pluck( $terms, 'term_id' );
// proceed with tax query
$args = array ('tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'term_id',
'terms' => $term_ids,
)
)
);
$city_posts = new WP_Query( $args );
Related Posts:
- “tax_query” parameter not working with WP_Query
- How do I exclude a custom taxonomy from the post loop
- Custom Taxonomy and Tax_Query
- display posts with same taxonomy term
- Display one post from each term in a custom taxonomy [closed]
- 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?
- How do I Use Multiple Loops with WP_Query?
- Hiding taxonomies with no children WP_Query & tax_query
- Set tax_query conditionally with new WP_Query
- Exclude taxonomy term from all loops, but having it on widget
- Using WP_Query and Query_post for the loop?
- 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?
- Custom Taxonomy + JQuery Tabs
- Advanced AND tax_query in sidebar with 2 taxonomies
- How to limit posts to 1 from each term with tax_query?
- Loop posts without any taxonomy
- Query custom taxonomy by term id?
- If Custom Taxonomy
- tax_query not working
- How can I reduce amount of ifs and else ifs in this specific block of code?
- Returning One custom taxonomy term name
- WP_query – Filter by tax_query and meta_query using multiple select
- When filtering query on custom taxonomy; main menu dissapears
- Why can’t I use an array of term slugs in WP_Query?
- wp_query not resetting, last post hanging
- WP_Query parameter conflict
- Problem with wordpress pagination
- Tax Query only returns for the first of several terms
- How to add tax_query to $args with concatenation
- 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
- display posts of custom post type with custom taxonomy
- Loop posts based on permalink term
- Loop to display ONLY custom taxonomy parent information [closed]
- tax_query (if the terms are empty)
- Check if a post has term inside loop
- Create alphabetical Pagination for custom taxonomy?
- Loop through custom taxanomy in post and display custom fields from posts
- Custom arguments in WP_Query
- How to restrict search on a certain page to only return results against custom taxonomies?
- Query Taxonomy By Page Title
- List all Custom Post Type posts excluding certain Taxnomy term
- Function using get_posts() with tax_query not working when called from functions.php
- 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
- List terms of custom taxonomy if matches other taxonomy
- 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
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Only display latest custom taxonomy post
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- 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
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- What is the most efficient way to execute recursive complex queries?
- Problem with sorting in custom child taxonomy archive page
- Get Posts Related to Category By category id or slug
- Display just the Post’s parent Category, not child
- display ACF repater field in archive page
- custom post type and a “sticky” position taxonomy
- How to add a shortcode function that returns the taxonomy slug of the actual post within the loop
- How do I stop the same post showing multiple times in a archive?
- Group posts in a category based on tags in custom 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?
- How to loop custom posts that have an exact match in taxonomy terms?
- list all post who have mutual taxonomy as current taxonomy!
- Get post meta value outside of the loop
- ACF – Get unique values of array
- Remove Custom metabox from particular page template is used
- Optimal way to make tags in tax_query optional?
- WP Query tax_query not returning posts
- 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
- WordPress Multiple Taxonomy Query
- How can I get all the posts that are related with a specific taxonomy term?
- Multi level archive
- How to combine nested tax_query logic with other nested query logic?
- tax_query not working for taxonomy slug
- Custom query for tag and custom tag from 2 post type
- List active taxonomy terms
- How to get hierarchical number of custom taxanomy
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- sort Posts by custom user filed
- Loop with Custom Post Type and Taxonomies