Sort Archive by name

  • May 31, 2018
  • Clients
  • 0 Comments
  • melissaSpiegel
add_action( 'pre_get_posts', 'my_change_sort_order'); 
    function my_change_sort_order($query){
        is_tax( $taxonomy, $term ):
         //If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type )
           //Set the order ASC or DESC
           $query->set( 'order', 'ASC' );
           //Set the orderby
           $query->set( 'orderby', 'title' );
        endif;    
    };

melissaSpiegel