Support

Home Forums Event Espresso Premium Widget Logic for EE event in specific category

Widget Logic for EE event in specific category

Posted: April 28, 2016 at 7:47 am

Viewing 1 reply thread


Miller Howard

April 28, 2016 at 7:47 am

I am trying to add a different sidebar element for EE events based on the category the event is tagged with. get_post_type() == ‘espresso_events’ works to display the sidebar on all single event pages, but get_post_type() == ‘espresso_events’ && is_category(‘shows’) does not display the sidebar on single events tagged with the Show category. How can I get this to work?


Josh

  • Support Staff

April 28, 2016 at 10:35 am

Hi Sydney,

It turns out that is_category() checks for if it’s a regular WordPress category archive page. When you check for a category or a custom taxonomy like espresso_event_category on a post, you can use
has_term().

https://codex.wordpress.org/Function_Reference/has_term

So for your example, you input
has_term( 'shows', 'espresso_event_categories' )

or if you only want the widget on single events (not displayed on a event category archive) :

is_singular() && has_term( 'shows', 
'espresso_event_categories' )
Viewing 1 reply thread

The support post ‘Widget Logic for EE event in 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