Force Search Results To Be In Alphabetical Order

By default, WordPress organizes posts within search results based on the post date.

You can easily override this by changing the OrderBy to Title.


function abc_search( $query ) {
	if( $query->is_search && !is_admin() ) {
		$query->set( 'orderby', 'title' );
		$query->set( 'order', 'ASC' );
add_filter( 'pre_get_posts','abc_search' );
See our featured website design work

Check out some of the beautiful websites we’ve built for over 2,000 clients.

We offer WordPress support & maintenance

Shake the stress of ongoing maintenance with plans supported by our team of WordPress experts.

Related articles