Include Additional fields in Search Results

Home Forums Calendar Products Events Calendar PRO Include Additional fields in Search Results

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1005469
    Pat
    Participant

    I have added the additional fields “target audience” and “event purpose” to my Events. However, the search does not seem to index these terms. So if I search on one of those terms, there are no results. For example, if I search for “Impact Investors” which is included in many events as the target audience, the search will find no results.

    #1005958
    Nico
    Member

    Hi Pat,

    Thanks for reaching out! Interesting question here.

    Right now there’s no easy way of doing this, and crafting a customization for this would be out of the scope of support we can provide here. That being said I can point you in the right direction to get started on crafting a solution for this, but you’ll need to code a bit for your self. Below you can find a snippet including a basic query sample:


    // get events additional fields
    $fields = tribe_get_option( 'custom-fields', false );
    //build the meta query
    $meta_query = array( 'relation' => 'OR');
    foreach ($fields as $field ) {
    // compare to search query = $query->query_vars['s'] or other value
    $meta_query[] = array('key' => $field['name'],'value' => $query->query_vars['s'],'compare' => 'LIKE');
    }
    // create args
    $args = array ( 'post_type' => 'tribe_events', 'meta_query' => $meta_query );
    // get posts
    $search_query = new WP_Query( $args );

    Please let me know if you think you can manage from here, and sorry for not having an easy fix for for this,
    Best,
    Nico

    #1010295
    Robin Jennings
    Participant

    This would be a fantastic new feature for the plugin

    #1010420
    Nico
    Member

    Hi Robin,

    I totally agree with you on this! You are welcome to suggest it as a feature in The Events Calendar user voice page – that’s the place where we gather feedback from our community regarding new features.

    Thanks,
    Nico

    #1015240
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Include Additional fields in Search Results’ is closed to new replies.