Tagged: , ,

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

    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.

    #562574

    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

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.