Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created February 6, 2017 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/16e7d2f1ca04ac9e6b8e154ecd2d5eca to your computer and use it in GitHub Desktop.
Save joshfeck/16e7d2f1ca04ac9e6b8e154ecd2d5eca to your computer and use it in GitHub Desktop.
Check if an event is in a particular parent category -- https://eventespresso.com/topic/check-if-an-event-is-in-a-particular-parent-category/
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE_event_details_before_post', 'my_custom_event_category_html' ); // can use a different hook here
function my_custom_event_category_html( $post ) {
$term_list = wp_get_post_terms($post->ID, 'espresso_event_categories', array( "fields" => "all" ) );
// print_r($term_list); // useful for debugging, commented out
foreach ( $term_list as $term ) {
if ( $term->parent == '116' ) { // parent category ID
echo '<h3>ABC</h3>';
return;
}
if ( $term->parent == '115' ) { // parent category ID
echo '<h3>XYZ</h3>';
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment