Add custom taxonomy to event search

WordPress Event Management, Calendars & Registration Forums General Question Add custom taxonomy to event search

This topic contains 2 replies, has 2 voices, and was last updated by  Stephen Harris 10 years, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #14449

    Hello,

    I have a custom taxonomy created for events and the event_search doesn’t search that taxonomy when I enter the taxonomy name in the search event field. I think it probably searches just titles or/with content. Is it possible to modify the event_search function to also include searches for that taxonomy? If so, can you navigate me how to do it because I don’t know how to get around that shortcode’s function.

    Thank you,
    Mark

    Marek Zelezny
    #14465

    Hi Marek,

    Unfortunately custom taxonomies aren’t supported – though it’s a good idea, so I’ll implement this for 1.11 (I’m afraid it’s too late for 1.10). This will give me a chance to refactor that monster of a file 😉

    Stephen Harris
    #14466

    I should add – the search part of the event search does indeed search titles/content (this is standard WordPress behaviour). You could use pre_get_posts to detect when an event search is being done, then use get_terms() to search for matching terms, and then modify the tax_query part of the query. However, I believe that would filter the events, i.e. it would only show events that were in a term LIKE the %search term%. That is WordPress would return “events that have title/content like X and are in term like X”. (If that makes sense…)

    Here’s how to catch an event search query

     add_filter( 'pre_get_posts', 'my_change_event_search' );
     function my_change_event_search( $query ){
    
          if( $query->get( 'context' ) == 'eo-events-search-shortcode' ){
              //$query is event search shortcode
          }
    
      }
    
    Stephen Harris
Viewing 3 posts - 1 through 3 (of 3 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.