Support

Home Forums Event Espresso Premium How to hide event from calendar, event widget, event table display

How to hide event from calendar, event widget, event table display

Posted: November 7, 2021 at 12:56 pm


Gilda Taffet

November 7, 2021 at 12:56 pm

We need to set up an event for a select number of donors but we need to not have the event display in the calendar, ESPRESSO_EVENTS_TABLE_TEMPLATE or the sidebar event display widget. I found this code which hides the event successfully using CSS from the calendar but I need help with also adding the CSS IDs for the table and widget displays.
#espresso_calendar a[href$=”/event-slug/”] {
display:none;
}

Thanks for your help!


Tony

  • Support Staff

November 8, 2021 at 6:24 am

Hi there,

Can you link me to the page you want to remove the event from and let me know which event to remove?

I should be able to give you a working example using CSS.


Gilda Taffet

November 8, 2021 at 10:55 am

Hi Tony, there are two pages where I need to be able to remove a specific event. Let’s use the one called Fruit Tree Care Talks as an example:
https://soilborn.org/calendar/
Need to remove it from both the calendar itself and the event display table that is on top of the calendar on this page.
Also need to remove from the event sidebar widget like the one on the home page:
https://soilborn.org/
And the table on this page (I think it is the same table that is not he calendar page…?):
https://soilborn.org/learn-grow/adult-ed/

Thanks for your help!


Tony

  • Support Staff

November 9, 2021 at 6:13 am

Hmm, without custom code this one is a little tricky as is.

The easiest way to remove those will be to add the event(s) to another category and then specifically target that category.

The table view doesn’t include the Event ID (or slug) within the individual table row, so you can’t easily target that specific event, however, it does output the events category slugs on those rows which you can target.

The same also applies to the calendar, now I know you already have a solution for it but this always you to use a single CSS selector for both.

For example, if you create a new category called ‘hidden’ (you can name it whatever you prefer) and assign this (and any other events you want to hide from view) to that category you can do something like:

#espresso_calendar .hidden,
#ee_filter_table .hidden {
    display: none;
}

To hide that from view on both the calendar and the events table at once.

The place where the above will not apply is the upcoming events widget (which you linked on your home page), you can use some additional CSS for that:

#ee-upcoming-events-widget-li-{event_id} {
    display: none;
}

So in your current example:

#ee-upcoming-events-widget-li-17703 {
    display: none;
}


Gilda Taffet

November 9, 2021 at 5:00 pm

Thank you SO much, this is exactly what I was looking for. I will implement your pieces of code to hide the event in the calendar, table and widget and let you know if I have any problems. Thanks!


Tony

  • Support Staff

November 10, 2021 at 3:53 am

You’re most welcome 🙂


Gilda Taffet

November 10, 2021 at 9:54 am

Hi Tony,

I assigned a new category of “hidden” to the event and applied the CSS snippets and the calendar and the widget responded perfectly and removed the event form their listing, yay! But the event still appears in the table list… If we wanted to try and target the specific event ID in the table since it is not responding to the new hidden category, how would we do that? The ID of the event we want to remove is 17890. Thanks very much for your help.


Gilda Taffet

November 10, 2021 at 10:20 am

I notice that there is the category-filter dropdown at the top of the page that directs what displays in the table list. I’m looking at the source code on the page but can’t figure out how to target the ‘hidden’ category. Is that maybe a way to get ‘hidden’ events to not show in the table list?


Tony

  • Support Staff

November 10, 2021 at 11:05 am

If we wanted to try and target the specific event ID in the table since it is not responding to the new hidden category, how would we do that? The ID of the event we want to remove is 17890.

You can’t on the table view template you are using, thats what I was referring to with:

The table view doesn’t include the Event ID (or slug) within the individual table row, so you can’t easily target that specific event, however, it does output the events category slugs on those rows which you can target.

The row doesn’t have the Event ID, or slug, for you to select using CSS.

Change the CSS I gave you earlier to be:

#espresso_calendar .hidden,
#ee_filter_table .hidden {
    display: none!important;
}

That should hide that event.


Gilda Taffet

November 10, 2021 at 11:12 am

Woot, that worked, thank you! I forgot you said the ID targeting won’t work with the table view template.

What does the !important code do?

Thank you very much for your help solving this!


Tony

  • Support Staff

November 10, 2021 at 11:29 am

What does the !important code do?

With CSS, styles override other styles based on ‘specificity’ so the rule that ‘wins’ is based on how specific the selector is and there is a specific way in which that is calculated, see:

https://css-tricks.com/specifics-on-css-specificity/

!important; on a specific rule basically sets it to the highest specificity and overrules everything, it should be used sparingly. The reason it works for you here is because the table has in-line styles setting the display property, so we need to override that and in this example using !important; is fine.

So to give an example, you could have:

.content p {
    /*Set the general font colour to red, any p tags in an element of class content*/
    color: red;
}
#special-content p {
    /*Set all text within p tags within an element with ID 'special-content' to use black */
    color: black;
}
p {
    /* Mehhh, any left over p tags can be set to yellow. */
    color:yellow;
}

Now the last CSS selector there is the least specific, just whatever p tags it finds, right? So that applies to everything and all paragraph text is yellow.

The first selector is a little more specific, . indicates a class, and you can have multiple elements with the same class, so it targets a p tag within an element that has a class of ‘content’. It’s more specific than the last rule, so ‘wins’ on those specific sections and makes those elements red.

The middle selector uses an ID ‘#’, you ‘should’ only have one element using any one ID on a page, mean using an ID is more specific than a class, so it ‘wins’ over the others.

Note the order of the CSS as it’s written, isn’t as important as how specific it is, which is why I wrote it in that order.

At that point, depending on the page markup you could have 3 different font colours on a single page. But, if I add !important; to:

p {
    /* Mehhh, any left over p tags can be set to yellow. */
    /* Actually, set it to be important, I want this to always 'win' */
    color:yellow!important;
}

All of the above basically goes out the window and every p tag ‘color’ attribute is overridden to use yellow. All text is yellow, because yellow is important.


Gilda Taffet

November 10, 2021 at 11:46 am

You’re the best, thank you for that info!


Tony

  • Support Staff

November 11, 2021 at 7:45 am

You’re most welcome.

The support post ‘How to hide event from calendar, event widget, event table display’ 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