You second query performs an entirely new query and does not have the terms set.
Besides, it’s not as efficient to ‘redo’ the query. Instead, hook into pre_get_posts
and change the order there:
function change_order_for_events( $query ) {
//Check if currenty query is the 'main query' and event type taxonomy being viewed
if ( $query->is_main_query() && is_tax('event_type')) {
$query->set( 'meta_key', '_wr_event_date' );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'change_order_for_events' );
For bonus points you might want to check that the ‘orderby’ and ‘order’ paramters are not set – that way ordering by date becomes default for events on the event type taxonomy pages but can be overridden if required.
All conditionals are available to you.
Related Posts:
- Order posts with custom taxonomy array
- Using wp_query is it possible to orderby taxonomy?
- “tax_query” parameter not working with WP_Query
- How do I exclude a custom taxonomy from the post loop
- Order get_terms using a Custom Field
- Custom Taxonomy and Tax_Query
- 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
- Select All in Parent Category, Group by Child Category?
- Including all terms in wordpress 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]
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- How can I set a default listing order on the admin page for a custom taxonomy? (without plugins)
- search query within custom taxonomy term, post title and meta field
- wp query with multiple taxonomy?
- wp_query orderby title and meta key value (WP3.1)
- On Taxonomy Template page, want to add Post_Type
- Page queried instead of a custom taxonomy
- Display Custom Taxonomy Terns ordered by meta_value
- The next_posts_link() show me a aditional page in blank
- List taxonomy terms plus their latest post ordered by post date
- Custom Taxonomy terms with latest post ordered by date pagination issue
- Help with a query not working with custom taxonomy
- Adding session variable and/or cookie based on user-selected input
- Ordering Posts with Custom Taxonomy Terms Array
- Excluding a custom taxonomy term breaks wp_get_post_terms
- Advanced Tax Query
- why do drafts return as part of wp_query?
- Improving WP_Query performance for multiple taxonomies
- WP Query with custom taxonomy
- how to search in custom fields & custom taxonomy for custom search
- WP_Query on custom taxonomy works fine but fails if run through wp_ajax_
- Advanced Query Logic With Multiple Taxonomies
- How do I Use Multiple Loops with WP_Query?
- cannot get multiple loops using tax_query
- Enable the admin to sort custom taxonomy
- orderby meta_value breaks taxonomy term archives
- Display all posts for taxonomy term across multiple custom post types
- Selecting all posts from the children of a particular parent taxonomy
- Sort order by slug for looped child terms of custom taxonomy
- Hiding taxonomies with no children WP_Query & tax_query
- Can I use OR relation for one item when calling tax_query from WP_Query and use AND for the rest?
- group posts by taxonomy terms
- Set tax_query conditionally with new WP_Query
- querying posts by custom taxonomy terms right from a querystring based URL
- Query custom taxonomy by term id?
- Weekdays as terms – How to order taxonomy terms by ID in admin panel?
- 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?
- Problem with wordpress pagination
- How to do a particular wp_query taxonomy search
- Wp_query…a type of term a different div
- check if a taxnomy queried in $wp_query?
- How to add a date creation field when a custom taxonomy relationship is created?
- Taxonomy.php how to show post only in current taxonomy with wp_query?
- WP_Query tax_query – Show results if child has parent X
- Query custom taxonomy for category including children
- Proper way to create taxonomy queries
- how to use tax_query to apply both terms or one if one is empty
- Get current page term title to use in WP_Query
- passing moree than one value of slugs in taxonomy using variable
- Order taxonomy terms wordpress
- Random order not working correctly when using default loop + $query->set
- Ignore punctuation marks in taxonomy order by name
- My custom query is displaying random posts in random order
- Orderby taxonomy term id using get_posts not working
- Change order custom taxonomy
- Sorting terms individually for each post
- How do you move custom fields to custom taxonomies using WP Queries
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- Run next query based on first query’s term
- Get the original menu item name string instead of the label
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Tax query array terms display out of order
- Sorting Custom Taxonomy in ASC/DESC order?
- Getting grandchildren of a post with a specified custom taxonomy?
- Taxonomy Parameters in WP Query to get posts from two different taxonomies
- Custom Taxonomy + JQuery Tabs
- Retrieve name or slug from get_objects_in_term
- Advanced AND tax_query in sidebar with 2 taxonomies
- Transfer taxonomy to custom field
- How to query posts that are not related to any term of a taxonomy?
- Using wp_query is it possible to orderby taxonomy?
- How to limit posts to 1 from each term with tax_query?
- Loop posts without any taxonomy
- Save selected terms in order of custom taxonomy in post
- WP_Query – Order results by meta value
- get_posts assigned to a specific custom taxonomy term, and not the term’s children
- How can I get only parent terms?
- Display all posts in a custom post type, grouped by a custom taxonomy
- How to modify a taxonomy that’s already registered
- Retrieve posts by term id custom query
- Change order of Custom Taxonomy List
- Get the the top-level parent of a custom taxonomy term