Support

Home Forums Event Espresso Premium EE4 is_espresso_event_single in sidebar?

EE4 is_espresso_event_single in sidebar?

Posted: December 12, 2017 at 6:08 pm

Viewing 2 reply threads


salda

December 12, 2017 at 6:08 pm

Hi there,

I’m currently customising the single-espresso_events file I’ve created in my theme, and I wanted to have a button in the sidebar that displays only on single pages. The documentation indicates I should be able to use the conditional:
is_espresso_event_single()

Which I’m using in this way:

if(is_espresso_event_single()) {
	echo '<div class="widget">';
	echo '<a href="'.get_permalink(325).'" title="Back to all events" class="std-btn">Back to all events</a>';
	echo '</div>';	
} else if (is_single()){
	echo '<div class="widget">';
	echo '<a href="'.get_permalink(7).'" title="Back to all news" class="std-btn">Back to all news</a>';
	echo '</div>';
}

The problem is that it appears to be ignoring the check for is_espresso_event_single – the single event pages are displaying the back to all news button that’s in the else if.
Is there something I’m missing? I’ve confirmed that the single-espresso_events.php file is being used on single events.

Cheers,
Min


Josh

  • Support Staff

December 12, 2017 at 6:21 pm

Hi Min,

is_single() will return true if it’s an Event Espresso post type single post, and is_espresso_event_single() appears to check the type of query.

Either of the following will test & return true:

if the current post is a single Event Espresso event post
if ( is_singular( 'espresso_events' ) )

or if single or if an archive:
if ( 'espresso_events' == get_post_type() )


salda

December 12, 2017 at 6:22 pm

Oh – I see! I assumed the is_espresso_event_single would be hit first and the subsequent is_single would be ignored, but that makes sense now.

Thanks for your help – got it working perfectly using
if ( is_singular( 'espresso_events' ) )

Viewing 2 reply threads

The support post ‘EE4 is_espresso_event_single in sidebar?’ 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