Skip to content

Posted in: Theming Snippets | View All

Important: Snippet Placement

Order Posts Alphabetically

Modifies the main query to sort posts alphabetically by title. Must be added to functions.php file of the Theme Customisations plugin.

      /* Order Posts Alphabetically */
function prefix_modify_query_order( $query ) {
  if ( is_main_query() ) {
    $query->set( 'orderby', 'title' );
    $query->set( 'order', 'ASC' );
  }
}
add_action( 'pre_get_posts', 'prefix_modify_query_order' );
  

Audit History

Passed | February 6, 2023 | By jcullen

Scroll To Top