How to search tags content

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 3 years, 2 months ago.

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

    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
    #39221

    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
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.