Support

Home Forums Event Espresso Premium All day events not working

All day events not working

Posted: August 31, 2021 at 6:48 pm

Viewing 22 reply threads


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 3 years, 2 months 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;
}


bhhsflpg

September 25, 2021 at 2:18 pm

Hi Tony,

Adding the CSS to remove the category button worked, but after adding the two snippets provided to fix the anchor issue, clicking on the categories to refresh the calendar still isn’t working as expected.

It seems like the code did get rid of the scrolling issue – the page does refresh on click. However, the page still shows events from all categories – not just the one that was clicked on.

See screenshot – clicked on “Special Events” category, but others still show.
https://www.dropbox.com/s/r31t40y9vh3eji6/Screen%20Shot%202021-09-25%20at%204.14.45%20PM.png?dl=0

Any ideas?

Thank you,
Stephanie


Tony

  • Support Staff

September 27, 2021 at 5:38 am

Adding the CSS to remove the category button worked, but after adding the two snippets provided to fix the anchor issue

Two snippets? You only need one of those JavaScript fixes.

However, the page still shows events from all categories – not just the one that was clicked on.

Hmm, strange. That’s not going to be from the JS code you just added, but it might be from the calendar filter we added earlier.

Can you add the latest version of the custom code in use on your site to a Pastebin again, please?


bhhsflpg

September 27, 2021 at 11:01 am

Hi Tony,

Here’s the pastebin link: https://pastebin.com/zV2Eddvq


Tony

  • Support Staff

September 27, 2021 at 1:29 pm

Ah, you missed a change from my above post: https://eventespresso.com/topic/all-day-events-not-working/#post-326670

Change line 79 in that gist from this:

if(is_array($unlisted )) {

to this:

if(is_array($category_id_or_slug)) {

That code is checking to see if a category has been passed to the shortcode and then stops modifying the query if it has and uses what has been passed over.

Right now that code is hooking into the query and basically telling the calendar to always pull all categories (excluding your unlisted one).


bhhsflpg

September 27, 2021 at 1:35 pm

Worked like a charm, thank you so much!


Tony

  • Support Staff

September 27, 2021 at 1:44 pm

You’re most welcome 🙂


bhhsflpg

September 28, 2021 at 3:49 pm

Oof, so sorry. Found one small new issue. We’re going to be using an embedded version of the calendar in another company system. Tested it today, and it seems like the hidden category is visible there, as well as the dropdowns for selecting category and venue, which are set to hide on the main version hosted on WP.

Is there a way to hide those here too?
– category dropdown
– venue dropdown
– category button for “unlisted events”

Screenshot: https://www.dropbox.com/s/ds1czejgjkmky2m/Screen%20Shot%202021-09-28%20at%205.46.33%20PM.png?dl=0

Can’t provide a link, it’s behind a login.


Tony

  • Support Staff

September 29, 2021 at 4:54 am

So the way I would do this is using a child theme, I can see you aren’t using one on the site currently but Elegant themes have a guide on creating on here:

https://www.elegantthemes.com/blog/divi-resources/divi-child-theme

If you then add the CSS styles to the Child themes style.css file rather than the customize option in the dashboard, they will automatically load on on the calendar iframe output.

Viewing 22 reply threads

The support post ‘All day events not working’ 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