Support

Home Forums Event Espresso Premium All day events not working

All day events not working

Posted: August 31, 2021 at 6:48 pm


bhhsflpg

August 31, 2021 at 6:48 pm

Hi,

I followed the instructions in the following article to create some all-day events. The purpose being to add holidays to show when our offices will be closed.

https://eventespresso.com/topic/setting-time-for-all-day-events/

I’ve added the custom plugin with provided code, and applied the custom field to a sample event, but the event time is still being displayed on both the event page and the calendar.

I’ve provided links to some screenshots for you.

Link to calendar page: https://blog.mycabcorner.com/company-calendar/
Link to sample event page: https://blog.mycabcorner.com/events/labor-day-2021/

{Removed}

Can you please let me know what I may have done incorrectly?

Thank you!
Stephanie

  • This topic was modified 2 weeks, 3 days ago by  Tony. Reason: Removed screenshots


Tony

  • Support Staff

September 1, 2021 at 3:41 pm

Hi Stephanie,

Just to confirm, in this screenshot: https://www.dropbox.com/s/e42inl0yp5b4a4l/Screen%20Shot%202021-08-31%20at%208.40.09%20PM.png?dl=0

Is the custom field set there named hide-event-time or hide-event-times (not the tailing ‘s’)

For the code linked above the custom field should be hide-event-times.

Also, that ‘Site plugin for {domain}’ plugin has been activated on the site, correct? (It’ll show in Dashboard -> Plugins).

The above is not going to hide the times on the calendar as that doesn’t isn’t used there. We can do that, but let’s get the above working on the single event page first.


bhhsflpg

September 1, 2021 at 4:29 pm

Hi Tony,

The custom field is “hide-event-times” – the s is just getting cut off in the view.

As far as the plugin goes, it’s not activated – but it’s also not showing up in the list to be activated. Did I miss a step somewhere when I created the plugin folder and file?


bhhsflpg

September 1, 2021 at 4:43 pm

This reply has been marked as private.


Tony

  • Support Staff

September 2, 2021 at 4:05 am

The custom field is “hide-event-times” – the s is just getting cut off in the view.

Ok, thank you, just checking as that would prevent it working.

As far as the plugin goes, it’s not activated – but it’s also not showing up in the list to be activated. Did I miss a step somewhere when I created the plugin folder and file?

Looks like the filename is missing the .php extension so it wont load.

Rename the file to customEEplugin.php

Does it show up then?


bhhsflpg

September 2, 2021 at 7:42 am

It shows up, but when I try to activate it get a fatal error. Here’s the screenshot.

https://www.dropbox.com/s/vhwd2megjv7o3lo/Screen%20Shot%202021-09-02%20at%209.31.42%20AM.png?dl=0


bhhsflpg

September 2, 2021 at 8:35 am

Also – as a followup, I also need plugin content to hide a category of events on our calendar. I found this article: https://eventespresso.com/topic/hide-a-category-shortcode-needed/

Do I create a second plugin? Or can I just add the additional function to the plugin I’ve created for all-day events?


Tony

  • Support Staff

September 2, 2021 at 9:57 am

Hmm, so you’re getting the fatal error because the custom plugin is loading after Event Espresso has loaded. Event Espresso checks for a function before declaring a new one, but if EE loads first and then the custom function tries to override the function, it’s already been declared so throws a fatal.

There’s a couple of solutions to this, the first is to use a hook within that custom functions plugin to load the functions before EE loads the template_tags.php file. Here is an example of doing that within that custom plugin:

https://gist.github.com/Pebblo/445913a847d645a82ef4ab7f9aef0355

That hooks into EE right before it includes the templat_tags.php file (which is where the espresso_list_of_event_dates function is declared, so declares it before EE gets the chance to.

The other option is to use a child theme and add the function to your themes functions.php file, which loads earlier in the request so should load before Event Espresso.

Do I create a second plugin? Or can I just add the additional function to the plugin I’ve created for all-day events?

You can add additional functions in the same plugin.

In my example you would add additional functions at the bottom of the file, after Line 60.


bhhsflpg

September 2, 2021 at 10:31 am

Hi,

That worked! I added that, the plugin activated, and I’m seeing no times on the event detail pages any longer.

However, they’re still showing on the calendar:
https://blog.mycabcorner.com/company-calendar/

I also added the hidden category code, and those are still showing as well. Ex – Sept 28th “One on Ones”

Thanks so much for all your help!


Tony

  • Support Staff

September 2, 2021 at 10:49 am

However, they’re still showing on the calendar:
https://blog.mycabcorner.com/company-calendar/

Yeah, that’s expected as that function isn’t used on the calendar.

You need another function, like this:

https://gist.github.com/Pebblo/2d39c12c71784576ef259e751aa0d8fb

I also added the hidden category code, and those are still showing as well. Ex – Sept 28th “One on Ones”

Can you copy all of the code you are using and add it to a Pastebin, then post the URL for that here so I can take a look?

(Whilst I appreciate the screenshots above, its harder to read code on a screenshot so the above is preferred if possible)


bhhsflpg

September 2, 2021 at 10:57 am

Boom! Added that additional function and the times aren’t showing on the calendar any longer.

Here’s the pastebin: https://pastebin.com/qp0TQQxn

The category I’m trying to hide on the calendar is “Unlisted Events” unique id = unlisted


Tony

  • Support Staff

September 2, 2021 at 11:36 am

Ok, change line 79 back from this:

if(is_array($unlisted )) {

To this:

if(is_array($category_id_or_slug )) {

The $category_id_or_slug variable used there is the category passed from the shortcode, if one is set, that function stops messing around with categories as one has been explicitly set by the admin. So thats not checking for a specific category, but checking the intent of the current code.

Line 91 is the part you are interested in:

if ($cat->term_id != 67) { // exclude this category only!

ID 67 is likely not going to match your category.

Go to Event Espresso -> Events -> Categories.

Find the ‘Unlisted’ category you created and note the ID of that category.

Now update 67 above to be that ID.

Does it work then?


bhhsflpg

September 8, 2021 at 10:08 am

Hi,

The provided code is working, thank you! Do have a couple of follow-up questions though.

I seem to remember that clicking on the category “buttons” at the top of the calendar used to refresh the calendar and show only items of that type. That’s no longer occurring?

Also – the “Unlisted Events” category shows within those buttons. Is that something that can be hidden as well?

Thank you!
Stephanie


bhhsflpg

September 13, 2021 at 10:45 am

Hi – just checking in on the message above


Tony

  • Support Staff

September 15, 2021 at 4:50 am

I seem to remember that clicking on the category “buttons” at the top of the calendar used to refresh the calendar and show only items of that type. That’s no longer occurring?

That’s happened because Divi is overriding the default browser behaviour for links with an anchor on them that goes to the same page. The buttons link to the page passing a category to the calendar and then sets an anchor so the browser goes directory to the calendar. The link looks something like this:

/calendar/?event_category_id={category}#espresso_calendar

The default behaviour for a link is to refresh the page and then scroll to the anchor (the element on the page with ID #espresso_calendar), with Divi they force the browser to scroll to that anchor.

One option to work around this is to use this snippet:

https://gist.github.com/Pebblo/2fe9648492d16108d121311c70235652#file-tw_ee_cal_remove_anchors-php

That will remove the anchor part of the link to stop it from happening, or you can use the second snippet in that link to remove the click event they are using and allow the default behaviour, either of those options should work.

Also – the “Unlisted Events” category shows within those buttons. Is that something that can be hidden as well?

You can hide it with some CSS:

#ee-category-legend-ul #ee-category-li-70,
#ee-category-submit option[value=unlisted] {
    display: none;
}

You must be logged in to reply to this support post. Sign In or Register for an Account

Event Espresso