Instead of creating a new query, consider reusing the existing global query:
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="container">
Then, to adjust the order, adjust the global query object by hooking into the pre_get_posts
hook:
/**
* Alters the tag archive query to sort ascending.
*
* @param WP_Query $query The WP_Query instance (passed by reference).
*/
function _alter_tag_archive_query( $query ) {
if ( ! $query->is_admin && $query->is_main_query() && $query->is_tag() ) {
$query->set( 'order', 'asc' );
}
}
add_action( 'pre_get_posts', '_alter_tag_archive_query' );
Related Posts:
- How to Order a list of taxonomies? orderby?
- How can I order a post query’s results based on the number of matching taxonomy terms?
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WP_Query orderby date not working
- Order by optional meta key?
- Sorting: custom query with orderby meta_value_num THEN by title
- Order by DESC, ASC in custom WP_Query
- WP_Query order by multiple meta keys & fields
- How does reset_postdata restore the post of the main query loop?
- WP query taxonomy input differs to output?
- Search custom taxonomy term by name
- Secondary Sort (fallback) for WP_Query
- Query Posts in a Predefined Order
- Where should you reset postdata?
- How to get order of posts?
- Order posts by ID in the given order
- Custom WP_Query order by post_meta and (author) user_meta
- Sorting posts by custom date fields (non standard date format)
- How to display post from current Taxonomy in archive page?
- Why should i use wp_reset_postdata()?
- Display posts the match taxonomy term linked from wp_list_categoies?
- How to order posts tag by tag?
- How do I order pages and categories by ID or name in the same query?
- Why is my WP_Query not working when tax_query terms are an array?
- When should you use wp_reset_postdata vs wp_reset_query?
- WP_Query ordered by custom field that is a date string?
- WP_Query sort by comment meta data
- Order posts by tags count?
- Merge 2 args in one WP_Query and order it by date
- Orderby = none not working [duplicate]
- Move posts to top of WP_Query if in certain Taxonomy?
- WP_query ‘orderby=none’ Problem
- Order posts by date and then by custom field
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Revolution Slider Orderby Two Custom Fields
- Querying Multiple Custom Taxonomy Terms
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- Order by the results of a function with WP_query
- How to order posts in wp_query by a meta_value of the corresponding author
- Filter and list posts of a custom taxonomy
- Order by menu structure
- WP Query – Get WooCommerce Products with variation that is in stock
- WP_Query order by date in meta_value
- Filter WordPress posts by between parameter
- How to Modify Taxonomy Archive Page with Search Parameter?
- How to use order RAND() on WordPress?
- Show all parents and children in custom post type in right order
- Ordering by meta_value AND date NOT WORKING with wp_query
- WP_Query orderby breaks when using AJAX?
- How to add terms to my tax_query based off of the current post
- Order WP Query posts by custom order calculated from post meta values
- Filtering posts by custom field value not working
- Custom Post order for homepage
- Meta query with order by another custom field
- Change default ordering of taxonomy terms – pre_get_terms
- Display link to taxonomy archive only if it has posts with certain custom field values
- WordPress WP_Query orderby being overwritten
- WP_Query Order by Specific Post ID First
- Order Posts by meta value AND published date
- How can I pick a single post from the latest 3?
- Wp query orderby ‘title’ doesn’t work
- Order taxonomy terms in alphabetical order
- Is it possible to dynamically get queried term AND taxonomy?
- WP Query for variable taxonomies
- How do I search inside specific taxonomies in WordPress
- Pass array of taxonomy terms to wp_query
- How can I order Wp_Query hierarchically?
- How do I sort posts with multiple pages
- Sorting posts DESC based on the number of comments using WP_Query
- Formulate a url to show posts with both taxonomy terms
- Order WP_Query by multiple fields, subtracting them from one another
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- pre_get_posts order by not working
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- Order by slug in get_terms with multiple taxonomies
- Output an array of terms for a ‘tax_query’ => array()
- Trouble with wp_reset_postdata() in Admin Panel
- Function get_queried_object() return NULL in custom taxonomy
- Getting Taxonomy inside WP_Query Loop
- (Solved) WP_Query ($ args) -> How to sort letters and numbers within the same array
- Reset postdata to custom query in nested queries
- Orderby ASC changes to DESC in WP_Query
- Complex WP_Query (two post types and multiple operators)
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Order By table field comment_status in WordPress > 4.0
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- Return Taxonomy/Term Information with Posts (WP_Query/get_posts)
- Complex WP_Query order request: DESC by day, but then ASC by time
- How to set multiple `orderby` in query argument?
- WP_Query order result by date AND meta_value
- Remove category from query (show all posts in archive.php) pre_get_posts()
- is_tax() function not working as expected
- Advanced Taxonomy Queries WordPress
- Order by title without taking into account ‘the’
- WP_Query orderby author__in
- Display Featured Post by Categories and Avoid duplicated posts
- How to orderby multiple meta fields if some fields are empty
- Sort wordpress custom posts based on meta value