Support

Home Forums Event Espresso Premium Custom code to run before shortcode

Custom code to run before shortcode

Posted: April 24, 2014 at 3:03 pm


adelardi

April 24, 2014 at 3:03 pm

Hi there,

I’m calling the event list shortcode via do_shortcode() inside a modal pop-up that runs as soon as you land on the home page but this is not the desired functionality in the event that there are no events to show.

Is there a snippet of code you can provide me that I can run before calling the EVENT_LIST shortcode so that I can add the shortcode conditionally to the page only when an event is coming up?

Thank you!


Dean

April 25, 2014 at 1:26 am

Hi,

There’s no specific snippet, you will need to play around with it and your own code, though a standard if/else is the most likely resolution.

1) You could do a database query to see if any events are upcoming and then and if/else statement on the results. Possibly over the top, but you would get an exact response.

2) You could do_shortcode into a variable and then check it to see if No events available… is in the string. Then do an if/else on the result. For example (pseudocode): if variable contains the string “No events available…” don’t do anything, else do this code for the modal box.

The support post ‘Custom code to run before shortcode’ 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