[Plugin: Events Manager] altering search query
-
Hi there again,
I need to alter my event search query so the user can select Multiple Categories when searching.
I have put Checkboxes in the search form for this purpose which would be passing their selections with the form output thusly
(sorry for the formatting but it mucks up when pasted here)
———————————-
<?php if( !empty($search_categories) || (get_option(‘dbem_search_form_categories’) && empty($search_categories)) ): ?>
<!– START multi select Category Search –>
<input name=”CatAll” type=”checkbox” value=”ALL”>All<?php foreach(EM_Categories::get(array(‘orderby’=>’category_name’)) as $EM_Category): ?>
<input name=”category[]” type=”checkbox” class=”em-events-search-category” value=”<?php echo $EM_Category->id; ?>” <?php echo (!empty($_REQUEST[‘category’]) && $_REQUEST[‘category’] == $EM_Category->id) ? ‘selected=”selected”‘:”; ?>><?php echo $EM_Category->name; ?>
<?php endforeach; ?>
<!– END Category Search –>
<?php endif; ?>
———————————-
I have used the format input name=”category[]” so that the GET result will create an array of selected values automaticallyThe input
<input name=”CatAll” type=”checkbox” value=”ALL”>All
can be used to determine whether to use any of the mutliselect values or not.………………..
Now I am trying to alter the SQL query to make use of this.
But can’t find where to go about that.
Looked in Tutorials at
https://wp-events-plugin.com/tutorials/create-your-own-event-scope/
and put a bit of code like that in my Theme’s functions.php
From that I can see the SQL array variables created including[category] => wp_em_events.post_id IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id=7 )
But then I get lost not knowing about term_taxonomy_id ??
It would seem that wp_term_relationships is a DB Table relating each event to the categories it belongs to ? That’s good.
And term_taxonomy_id would be the one I selected in the normal form’s selection dropdown.
But when I think about how to use this process to alter the query in the way I need to I realise that I will need access to the array of Categories which will be being returned in the GET from the form and no idea how to get hold of that.So what I need I think is where the SQL is actually created from the GET results
OR
Maybe someone to code this change for a fee ?? ??
- The topic ‘[Plugin: Events Manager] altering search query’ is closed to new replies.