Hello,
Can you help me modify search code for dynamic search in main menu to have posts above pages in dynamic search results? How can I switch code to get first posts results than pages?
Thank you.
Hi rimlightstudio!
That’s kind of bordering on custom work.
You can see where they are sorted around line 190 in the /enfold/functions-enfold.php file.
//if we got posts resort them by post type
$output = "";
$sorted = array();
$post_type_obj = array();
foreach($posts as $post)
{
$sorted[$post->post_type][] = $post;
if(empty($post_type_obj[$post->post_type]))
{
$post_type_obj[$post->post_type] = get_post_type_object($post->post_type);
}
}
I imagine pages comes before posts naturally because of alphabetical order.
Maybe something like this might work.
$copy0 = $sorted[0];
$copy1 = $sorted[1];
$sorted[0] = $copy1;
$sorted[1] = $copy0;
Best regards,
Elliott