Support

Home Forums Event Espresso Premium Upcoming Events Widget (5)

Upcoming Events Widget (5)

Posted: September 4, 2018 at 1:45 pm

Viewing 2 reply threads


asse2014

September 4, 2018 at 1:45 pm

Is there a way to auto hide the Upcoming Event Widget if there are no other events scheduled? Especially interested in auto hiding from the Single Event listing, since many times, it is the only one event scheduled and when you view details, the Upcoming Events Widget is blank.

If cannot auto hide, can the widget state, “There are currently no events scheduled.”?

Using Upcoming Event widget with Version 4.9.67.p.

  • This topic was modified 6 years, 2 months ago by asse2014.
  • This topic was modified 4 years, 8 months ago by Garth.


Josh

  • Support Staff

September 4, 2018 at 8:39 pm

Hi,

You can add the following code to hide the widget if there are no events:

function my_hide_widget_if_no_events() {
    $script = 
    '<script>jQuery( document ).ready( function( $ ){
        if( !$("ul.ee-upcoming-events-widget-ul").has("li").length ) {
        $(".widget_ee-upcoming-events-widget").hide();
        }
    });</script>';
    echo $script;
}
add_action( 'wp_footer', 'my_hide_widget_if_no_events', 20 );

You can add the above to a functions plugin or into your WordPress child theme’s functions.php file.


asse2014

September 5, 2018 at 9:27 am

Thank you… worked perfectly!!

Viewing 2 reply threads

The support post ‘Upcoming Events Widget (5)’ 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