Hi the default wordpress search seems to be for "piano"
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE '%piano%') OR (wp_posts.post_excerpt LIKE '%piano%') OR (wp_posts.post_content LIKE '%piano%'))) AND wp_posts.post_type IN ('post', 'page', 'attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 5 AND wp_posts.post_status = 'private') ORDER BY wp_posts.post_title LIKE '%piano%' DESC, wp_posts.post_date DESC LIMIT 0, 25
however I need them all sorted by date first. My search results by date are skewed:
2020-10-25 2020-10-22 2020-10-20 2020-10-20 2020-10-16 2020-10-13 2020-10-10 2020-10-07 2020-10-06 2020-10-02 2020-09-30 2020-09-28 2020-09-02 2020-08-09 2020-07-21 2020-07-21 2020-05-21 2020-04-24 2020-03-06 2019-06-02 <- here it is skewed onwards 2019-06-01 2020-10-25 2020-10-24 2020-10-23 2020-10-23
So I asume it is because the SQL query sorts by title first.
So I tried this solution:
function changeSearchSort( $ orderby, $ query ){ global $ wpdb; if(!is_admin() && is_search()) { $ orderby = $ wpdb->prefix."posts.post_date ASC"; } return $ orderby; } add_filter('posts_orderby','changeSearchSort',10,2);
from here How do I change WP search results order?
and it does not work.
I have tried this:
a) disabled all plugins
b) different themes
still not working.
Help appreciated
cheers
Ben