WordPress by default order posts in descending order by date. But I want them to be in ascending order by date.

How do I turn the order to ascending only for tags and category? I don't want blog post orders to change.

  • Please edit the question giving us information on how do you retrieve posts on these pages.
    – Max Yudin
    Feb 6, 2019 at 8:05
  • Man! I don't understand that much WordPress coding. I have only styled the archive.php no change in function. The post on my categories orders in Ascending and order by date. They are ordered on basis of new dates to older dates. Now, I want them to be in descending.
    – Bikram
    Feb 6, 2019 at 8:14
  • Having no coding experience you have to search for a plugin to achieve the goal.
    – Max Yudin
    Feb 6, 2019 at 8:36
  • No problem dude, I found an answer to this question wordpress.stackexchange.com/questions/39817/…. I put the order to my desire. Answered by Stephen Harris.
    – Bikram
    Feb 6, 2019 at 8:41
  • If you are interested in a plugin-like solution: I would recommend any of these two plugins: Chronological Posts (reverses post order for all category archives) Post Order By Category (reverses the post order for a specific category)
    – Badan
    Nov 27, 2019 at 21:47

1 Answer 1


You can use pre_get_posts action to modify this order. Here's the code:

function my_change_posts_order( $query ){
    if ( ! is_admin() && ( is_category() || is_tag() ) && $query->is_main_query() ) {
        $query->set( 'order', 'ASC' );
add_action( 'pre_get_posts', 'my_change_posts_order'); 

What we do here is:

  1. We're adding our function that will modify params for WP_Queries
  2. We make sure that it will change only main query (the one created by WordPress) and only on category and tag listings ( is_category() and is_tag()).
  3. We change the order of posts for these pages by setting order to ASC

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.