Search Results Order

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 3 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24391

    I am looking for a way so the top search results would show the posts in order according to the menu nav if possible. Currently the top results that show are not in the order I want. I looked all over and can’t seem to find any way to do this.

    #24402
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Well, it is not possible via options, but it might be possible with a custom code.

    Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter( 'asp_query_args', 'asp_custom_menu_order', 10, 1 );
    function asp_custom_menu_order($args) {
    	global $wpdb;
    	$args['cpt_query'] = array(
    		'fields' => "$wpdb->posts.menu_order as menu_order, ",
    		'join'	 => '',
    		'where'	 => '',
    		'orderby'=> 'menu_order DESC, '
    	);
    	return $args;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.