Posted: January 29, 2016 at 5:40 am
|
Hi – I run training courses – some are scheduled to run regularly and I use Event Espresso 4 to manage these – some are only available for bespoke, custom bookings, which I book in manually. On my course pages I’m using [ESPRESSO_EVENTS category_slug=”course-name”] to get a list of upcoming scheduled courses. If there are no scheduled upcoming courses nothing displays – however instead of this, if there are no scheduled upcoming courses I’d like to diaply an alternative message to remind my visitors that they could always book an bespoke course instead. To precis: I want to display a custom message if there are no courses in that category upcoming. thanks! Andrew |
Hi Andrew, Thats a really good idea. I looked at this on my current theme on my testing site and here is how I set it up. The [ESPRESSO_EVENTS] shortcode uses an archive.php theme template in your theme folder. You can create a separate template for Event Espresso to use. 1) Create a child theme that will hold your customizations: https://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme 2) Duplicate an existing parent theme template such as an archive.php and then rename to archive-espresso_events.php. Now you’ll want to change the messaging that is shown when no content (e.g. events) are available. 3) Open the new archive-espresso_events.php for editing. Here is what mine looks like: The highlighted are is the reference to the theme content file that is used when there is no content available. You may see something similar but it won’t be an exact match since you are not using the same theme: http://cl.ly/3G1s2i2l0W1v 4) The next step is to duplicate the content-none.php (note your filename may be different) that is being used and create another one. Then that new file name should be referenced in the archive-espresso_events.php file. For example, here I changed it to look for a file called content-noevents.php: http://cl.ly/082e3U2Q0M0U 5) Then I edited the content-noevents.php file to have new messaging: — |
|
|
Hi Lorenzo, Sorry for the very long wait for me to get back – I stumbled over a bunch of other issues which I’ve now resolved. Meanwhile… I’ve now tried your suggestion of adding an else statement to the loop in my archive.php or duplicated archive-event_espresso.php templates. However, neither of these templates seem to be providing anything that’s being generated by my [ESPRESSO_EVENTS] shortcode. Even if I delete all the contents of these files the [ESPRESSO_EVENTS] shortcode still generates content (if there are upcoming events that is) – where might I find the source for the [ESPRESSO_EVENTS] shortcode if not in my themes archive.php or archive-event_espresso.php? thanks! Andrew |
Hi Andrew, It turns out the shortcode doesn’t use the templates that Lorenzo referred to. If you look in loop-espresso_events.php you’ll find that it will load If your theme has a content-none.php file, that’s the file to edit, and if you can post the contents of the content-none.php file in a pastebin or gist, we can take a look and give you further suggestions on how to add a conditional check for events and a custom message there. |
|
|
Thanks Josh, that seems to work. thanks, Andrew |
Yeah that will work. |
|
The support post ‘If no upcoming events in a category – how to present custom message’ 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.