Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1061086

    Hi

    I would like to change to ASC order by date in the specific taxonomy archive pages

    The current archive pages of all categories and taxonomies are Desc order by date.

    If possible, I would like to know how to do it?

    Thank you

    • This topic was modified 5 years, 10 months ago by kmotoyama.
    #1062230

    Hey Koji,

    Please refer to a solution posted here
    https://wordpress.stackexchange.com/a/39818

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1062453

    Hi, Victoria

    Thank you for your support.

    I tried it. Unfortunately, it did not work for my site.
    However, I found another solution to use plugin “Archive Posts Sort Customize,” it works well.

    I tried it again, because this plugin is too old ever though it works well.
    Here is my code. It works.

    add_action( 'pre_get_posts', 'my_change_sort_order'); 
        function my_change_sort_order($query){
            if(is_tax( 'your taxonomy name' ) && ! is_tax( 'your taxonomy name', 'exclude slug name' ) ):
             //Change "your taxonomy name" and "exclude slug name"
               //Set the order ASC or DESC
               $query->set( 'order', 'ASC' );
               //Set the orderby
               $query->set( 'orderby', 'date' );
            endif;    
        };

    Thank you again
    Koji

    • This reply was modified 5 years, 10 months ago by kmotoyama.
    #1063288

    Hi Koji,

    Glad you got it working for you and thank you for sharing your solution! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.