-
AuthorPosts
-
April 27, 2016 at 4:48 pm #623211
Hi currently the search page showing all the results but it displaying posts (portfolio, other post types) result first then the page result so i want to display the wordpress page that contain the search keyword result first then the posts that contain search keyword.
April 30, 2016 at 11:39 am #624925Hi,
Can you post the link to your website please?
Regards,
JosueMay 2, 2016 at 6:51 am #625474Hi please find the link below
May 2, 2016 at 8:00 am #625508Hi,
Since enfold only uses the default wordpress search you would need to use a plugin to do something like that. Its unfortunately quite hard to group the search results as you would require it (the wordpress default ist to mix those and list them by date) so I dont think there is a simple code snippet that we can offer that fixes this for you.
However, some of the more advanced search plugins might work fine for you. eg:
https://wordpress.org/plugins/relevanssi/It states that it can sort results by relevance and not by date, which might work fine for you ;)
Best regards,
KriesiMay 2, 2016 at 8:24 am #625527Thanks for the reply but if you are using default wordpress search then why post coming up it can be pages or else is there any custom query or is there any way to modify search query.
May 2, 2016 at 9:12 am #625558Hi,
The default query sorts all entries based on the date. You can of course try to use a snippet like this in your themes/child themes functions.php but I consider not messing with it and using a plugin the better option.
But feel free to try this, I found it on stackoverflow, maybe it works as you want it :)
add_filter( 'posts_clauses', 'post_query_order', 20, 1 ); function post_query_order( $pieces ) { global $wpdb; $pieces['orderby'] = $wpdb->prefix.'posts.post_type ASC'; return $pieces; }
Best regards,
KriesiMay 4, 2016 at 7:44 am #626954Hi the above code still not full filling the requirement more over the code is affecting over all site. I want to modify the query only for the search result.
May 4, 2016 at 11:06 am #627065 -
AuthorPosts
- You must be logged in to reply to this topic.