Support

Home Forums Event Espresso Premium EE4 Show Event Category w/o Link and check if Event is in a specific category

EE4 Show Event Category w/o Link and check if Event is in a specific category

Posted: August 21, 2014 at 9:53 am


Jenny Volvovski

August 21, 2014 at 9:53 am

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?

I’m using WP 3.9.2, and the EE4

Thanks,
Jenny


Josh

  • Support Staff

August 21, 2014 at 3:48 pm

Hi Jenny,

This is possible. Some example code follows:

// 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' );

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.

Event Espresso