Home › Forums › Calendar Products › Events Calendar PRO › Adjust AJAX search to exclude event taxonomy
- This topic has 5 replies, 4 voices, and was last updated 9 years, 2 months ago by
Diego Hinz.
-
AuthorPosts
-
February 2, 2017 at 8:01 am #1228167
Diego Hinz
ParticipantDear Support-Team,
I have been trying to exclude one event taxonomy from the frontend of my website. This has worked out quite well so far, until I tried to filter the AJAX search output.
My Code so far is as follows:
/* Exclude non-booked events from frontend calendar */
function tribe_exclude_events_category( $wp_query ) {
$exclude_cats = array('easytruck-offen');
if ( is_admin() ) return $wp_query;
if (is_array($wp_query->tax_query))
$tax_query = $wp_query->tax_query;
else
$tax_query = array();
$tax_query[] = array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => $exclude_cats,
'operator' => 'NOT IN'
);
if (tribe_is_event_query()) {
$wp_query->set('tax_query', $tax_query);
}
return $wp_query;
}
add_action( 'pre_get_posts', 'tribe_exclude_events_category', 100, 1 );This works well with all Calendar views and all WordPress search pages, however, the installed theme utilizes an AJAX search box in the header, which still displays posts from the unwanted taxonomy.
The AJAX search file defines the variable
$td_queryas follows:
$td_query = &td_data_source::get_wp_query($ajax_parameters['td_atts'], $ajax_parameters['td_current_page']);get_wp_query()looks like this:
static function &get_wp_query ($atts = '', $paged = '') {
$args = self::shortcode_to_args($atts, $paged);$td_query = new WP_Query($args);
return $td_query;
}My question: Is it possible to alter the function tribe_exclude_events_category() to also address the $td_query? Would you need additional information for this?
Thank you in advance!
Have a great day!February 2, 2017 at 8:07 am #1228172George
ParticipantHey Diego,
Thanks for reaching out.
The things you’re trying to do are technically possible, but they are unfortunately all related to custom coding and modifying core functionality of our plugins. These things are outside the scope of the support we can provide, unfortunately. Read more here: https://theeventscalendar.com/knowledgebase/what-support-is-provided-for-license-holders/
You may be able to keep an event from a certain taxonomy hidden just be way of CSS alone. Even if you’ve already tried this, can you share with me the term and the taxonomy (tag? event category? custom taxonomy?) you’re trying to exclude?
As noted we can’t help with this sort of thing, but I might be able to recommend a bit of custom coding for you nonetheless that will help hide those events—even after interacting with AJAX features, etc.
Thanks,
GeorgeFebruary 3, 2017 at 6:13 am #1228871Diego Hinz
ParticipantHi George,
Thank you for your quick reply! I understand that this request exceeds the scope of the support offered to license holders.
The category we want to remove from all frontend queries is ‘easytruck-offen’. We use this taxonomy to register events that are not publicly accessible but needed for internal purposes. When these events become public, we switch to the category ‘easytruck’.
The CSS solution is not viable unfortunately, as we are also using e.g. the mini-calendar shortcode. There, the class “tribe-events-has-events” is set for days that have events, so even after hiding the actual event via CSS, the mini calendar would still indicate an event on that day.
Is it possible to have this custom code developed by you and your team? What information would you need to make a proposal?
Best Regards!
February 6, 2017 at 9:35 am #1230028George
ParticipantThanks for elaborating here, @Diego. I now understand why CSS may not be the best fit.
To implement the features you describe, it’s unfortunately not something we can help with here. You would have to write that custom code or hire a professional developer to do it for you. We have a list of great developers here → http://m.tri.be/18k1 (and have no affiliation with any of these folks—they’re simply some well-respected names in the community that we’ve compiled to share in situations like this one).
Please let me know if there are any other issues or questions I can try to help with!
— George
February 28, 2017 at 8:35 am #1246939Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Adjust AJAX search to exclude event taxonomy’ is closed to new replies.
