How to sort Location Profiles in alphabetical order

Using the WordPress pre_get_posts filter you can create a simple function to adjust the default sort of location profiles custom post type with the following function.

Add the following function to your theme functions file or custom plugin.

function my_epl_location_profiles_default_sort( $query ) {
	// Do nothing if in dashboard or not an archive page
	if ( is_admin() || ! $query->is_main_query() )

	// Do nothing if doing search
	if ( epl_is_search() )

	// Sort EPL listings by price on archive page
	if ( is_post_type_archive( 'location_profile' ) ) {

		$query->set( 'orderby', 'title' );
	    	$query->set( 'order', 'ASC' );
add_action( 'pre_get_posts', 'my_epl_location_profiles_default_sort' , 20  );