Skip to content

Instantly share code, notes, and snippets.

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 Pebblo/042f04c9af5d03a70206e681ee28af84 to your computer and use it in GitHub Desktop.
Save Pebblo/042f04c9af5d03a70206e681ee28af84 to your computer and use it in GitHub Desktop.
Display the description for the category/categories that are assigned to a single event. Requires Event Espresso 4. You can add this code to a <a href="http://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/">functions plugin</a> or into your WordPress theme's functions.php file.
<?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_the_content', 'ee_display_tags_and_categories_single_event' );
function ee_display_tags_and_categories_single_event( $post ) {
$taxonomy = 'espresso_event_categories';
$terms = get_the_terms( (int) $post->ID, $taxonomy );
$tags = get_the_tags( (int) $post->ID );
// Output event categories
if( !empty( $terms ) ) {
foreach( (array) $terms as $order => $term ) {
if( !empty( $term->description ) ) {
echo '<h4>' . $term->name . '</h4>';
echo '<p>' . $term->description . '</p>';
}
}
}
// Output event tags
if( !empty( $tags ) ) {
echo '<ul>';
foreach( (array) $tags as $tag ) {
echo '<li>' . $tag->name . '</li>';
}
echo '</ul>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment