Is there any way to show the event category without the link in EE4?
I know how to do it using espresso_event_categories(), but I just want to have the name of the category displayed.
I’d also like to set up an if statement for a specific category. Is this doable?
// function to echo categories with no links
//
function event_categories_no_links( $EVT_ID = FALSE, $hide_uncategorized = TRUE ) {
$category_names = array();
$event = EEH_Event_View::get_event( $EVT_ID );
if ( $event instanceof EE_Event ) {
if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
// loop thru terms and return names
foreach ( $event_categories as $term ) {
if ( (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
$category_names[] = $term->name;
}
}
}
}
echo '
' . implode( ', ', $category_names ) . '
';
}
// now you can place event_categories_no_links() in your template
//
// -or-
//
// use a hook, for example to display the list of categories after the content:
//
add_action ( 'AHEE_event_details_after_the_content', 'event_categories_no_links' );
Viewing 1 reply thread
The support post ‘EE4 Show Event Category w/o Link and check if Event is in a specific category’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.