How do I prioritize posts over pages in a wordpress/genesis search result page? Similar to this code, except I'd like posts to show before pages and I can't seem to fully adjust this code to do it:
function change_search_result_order($query) {
// Check if current page is search page
if ($query->is_search) {
// Specify orderby and order, ordering will be by slug of post_type: pAge > pOst
$query->set('orderby', 'post_type');
$query->set('order', 'ASC');
};
return $query;
}
add_filter('pre_get_posts', 'change_search_result_order');
this code block was also mentioned, but I can't seem to find where it fits--if I could, would it be as simple as switching page and post?
$query->set('post_type', array('page','post'));
Original source: How to prioritize pages over posts when searching?
thanks in advance! Adam