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.
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.
Support forum for Event Espresso 3 and Event Espresso 4.