frankyonnetti
1/14/2017 - 9:16 PM

WordPress Archive Sort Order.php

WordPress - archive sort order #wordpress #sortorder

<?php

/**
 * Change the order by title.
 */

  function foo_archive_sort_order($query) {
    // If you wanted it for the archive of a custom post type use: 
    is_post_type_archive( $post_type )
    if( !is_admin() && is_archive() ):
      $query->set( 'order', 'ASC' );
      $query->set( 'orderby', 'title' );
    endif;
  };
  add_action( 'pre_get_posts', 'foo_archive_sort_order');