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
- The Operator “NOT IN” Does Not Work In tax_query
- 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)
- Group posts that matches a term in a loop
- Custom taxonomy template loop
- Custom WP_Query breaks default behaviour of viewing right post associated with tax-term!
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- Adding session variable and/or cookie based on user-selected input
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- List taxonomy / category count showing list published posts only
- Excluding a custom taxonomy term breaks wp_get_post_terms
- Query for posts in 2 taxonomies
- tax_query shows no results if nothing is selected
- Improving WP_Query performance for multiple taxonomies
- Modify main loop in taxonomy archive page
- How to output content based on same custom taxonomy?
- How do I sort posts by custom taxonomy?
- All posts are still shown when adding category argument to query
- WP_Query, tax_query and term_meta: How to?
- How to add autocomplete to custom taxonomy for CPT
- Operations with custom fields values in a loop
- WP_Query on custom taxonomy works fine but fails if run through wp_ajax_
- Advanced Query Logic With Multiple Taxonomies
- echo current taxonomy id for this loop?
- Custom loop with multiple taxonomy queries
- Posts in loop displaying all taxonomies
- Retrieve Custom Taxonomies according to posts selected
- Custom Taxonomy Not Working When added to WordPress Search
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- 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
- tax_query not working in template
- If Custom Taxonomy
- 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
- WP_Query parameter conflict
- 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
- Loop posts based on permalink term
- tax_query (if the terms are empty)
- Check if a post has term inside loop
- List all Custom Post Type posts excluding certain Taxnomy term
- Function using get_posts() with tax_query not working when called from functions.php
- 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?
- List terms of custom taxonomy if matches other taxonomy
- Get current page term title to use in WP_Query
- passing moree than one value of slugs in taxonomy using variable
- how to get the post id in the option tag
- 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?
- 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 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?
- list all post who have mutual taxonomy as current taxonomy!
- WP Query tax_query not returning posts
- 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
- Custom query for tag and custom tag from 2 post type
- List active taxonomy terms
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- How to get name of custom taxonomy
- Post data in separate divs with incrementing class using WP_Query
- How do you move custom fields to custom taxonomies using WP Queries
- Order posts with custom taxonomy array
- Getting grandchildren of a post with a specified custom taxonomy?
- Taxonomy Parameters in WP Query to get posts from two different taxonomies
- WordPress show posts from children terms of a taxonomy term
- Loop custom post type by taxonomy (Category)
- display custom post type from register taxonomy
- Output ACF field dynamicaly within a taxonomy loop [closed]
- wp_get_object_terms count on taxonomies within an category archive