Skip to content

Commit

Permalink
Made post type archives ordered by title ascending.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rarst committed Jan 5, 2014
1 parent 7ae23b9 commit cf7b73d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,26 @@

namespace DevHub;

add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\theme_scripts_styles' );
add_action( 'init', __NAMESPACE__ . '\\init' );


function init() {

add_action( 'pre_get_posts', __NAMESPACE__ . '\\pre_get_posts' );
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\theme_scripts_styles' );
}

/**
* @param \WP_Query $query
*/
function pre_get_posts( $query ) {

if ( $query->is_main_query() && $query->is_post_type_archive() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}

function theme_scripts_styles() {
wp_enqueue_style( 'wp-doc-style', get_stylesheet_uri() );
wp_enqueue_style( 'droid-sans-mono', '//fonts.googleapis.com/css?family=Droid+Sans+Mono' );
Expand Down

0 comments on commit cf7b73d

Please sign in to comment.