Hello Stephen, trying to wrap my head around the search function.
As far as I understand, the search looks for matches inside title and event content?
My goal is: If I have an event that has a tag named ‘zebra’ and I search for zebra via the [event_search]
widget , I wish to have that event in the search results, even if there’s no mention of zebra in the title nor event description.
Is this possible?
(I found search related code in includes/shortcode.php
includes/functions.php
and of course in the template, without finding anything illuminating)
Thanks! Andrea
andrebalza
Hi Andrea,
Yes, the event search is the same as search for ‘posts’ – just for a different post type.
It is possible to extend this, but it’s not supported ‘out of the box’, so you would need to code this yourself or use a plug-in which provides that feature. See this answer, for instance: https://wordpress.stackexchange.com/questions/2623/include-custom-taxonomy-term-in-search
If you do opt to code this yourself I would recommend following’s Evan Mattson’s comments and use the secondary parameter passed to the atom_search_*
functions rather than using global $wpdb
. E.g.
function atom_search_where($where, $query){
global $wpdb;
if ($query->is_search() && eventorganiser_is_event_query($query) ) {
$where .= $wpdb->prepare( "OR (t.name LIKE %s AND {$wpdb->posts}.post_status = 'publish'", "%" + $wpdb->esc_like( $find ) + "%");
}
return $where;
}
add_filter('posts_where','atom_search_where', 10, 2);
Stephen Harris