Created
February 6, 2017 18:30
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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