Created
May 4, 2015 07:54
-
-
Save mayeenulislam/965fa5ee36b96e6a677e to your computer and use it in GitHub Desktop.
WordPress - ascending or alphabetical order search result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Ascending order search result - WordPress | |
* @param object $query | |
* @return void | |
*/ | |
function wp20150504_alphabetical_search_query( $query ) { | |
//checking whether we are in the search result page or not | |
if ( $query->is_search && $query->is_main_query() ) { | |
//setting/forching our desired order parameter o'er the default | |
$query->set( 'order', 'ASC' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'wp20150504_alphabetical_search_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment