Wordpress Search Query not returning User -
when search user first name, of posts show in dashboard. when search same user , add last name, not show @ all. not sure why happening author. have made settings same other users have written posts well.
here's first search url , query, returns posts written user. http://trochia.org/?s=dani
when add last name, there no results. http://trochia.org/?s=dani+nichols
here's user, no issue first name or combination of first , last name. http://trochia.org/?s=fred http://trochia.org/?s=fred+gladney
figured out.
function atom_search_where($where){ global $wpdb; if (is_search()) $where .= "or (t.name '%".get_search_query()."%' , {$wpdb- >posts}.post_status = 'publish')"; return $where; } function atom_search_join($join){ global $wpdb; if (is_search()) $join .= "left join {$wpdb->term_relationships} tr on {$wpdb->posts}.id = tr.object_id inner join {$wpdb->term_taxonomy} tt on tt.term_taxonomy_id=tr.term_taxonomy_id inner join {$wpdb->terms} t on t.term_id = tt.term_id"; return $join; } function atom_search_groupby($groupby){ global $wpdb; // need group on post id $groupby_id = "{$wpdb->posts}.id"; if(!is_search() || strpos($groupby, $groupby_id) !== false) return $groupby; // groupby empty, use ours if(!strlen(trim($groupby))) return $groupby_id; // wasn't empty, append ours return $groupby.", ".$groupby_id; } add_filter('posts_where','atom_search_where'); add_filter('posts_join', 'atom_search_join'); add_filter('posts_groupby', 'atom_search_groupby');
Comments
Post a Comment