todays event only widget

This topic contains 4 replies, has 3 voices, and was last updated by  Stephen Harris 11 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5330

    I couldn’t find or work out if its possible to display just the events for today’s date in the widget area.

    Thanks
    Nick

    Nick
    #5445

    anyone?

    I couldn’t find or work out if its possible to display just the events for today’s date in the widget area.

    Thanks
    Nick

    Nick
    #5483

    This is not possible with the standard widget.

    If you have the capabilities to make your own widget, then the following code should get events for that period.

    <?php
    $events = eo_get_events(array(
    'events_start_after'=>'yesterday',
    'events_start_before'=>'tomorrow',
    ));

    if( $events ){
    global $post;
    echo '<ul>';
    foreach( $events as $post ){
    setup_postdata($post);
    ?>
    <li>
    <a href='<?php the_permalink() ?>'>
    <h5><?php the_title(); ?></h5>
    <p><?php echo eo_get_venue_name(); ?> on the <?php echo eo_get_the_start('jS F'); ?></p>
    </a>
    </li>
    <?php
    }
    echo '</ul>';
    wp_reset_postdata();
    }else{
    echo '<h5>No Events Today</h5>';
    }
    ?>

    Dario
    #5484

    Here’s a link to the above code, all nicely set out: http://cl.ly/OENj

    Dario
    #5495

    Hi Nick,

    There’s no existing option for that, but as Dario has said you can create your own widget to do this.

    A minor correction to Dario’s post, the query should be:

    $events = eo_get_events(array(
         'events_start_after'=>'today',
         'events_start_before'=>'today',
      ));
    

    As the event date attributes are inclusive. Of course that retrieves events that start that day, if you have an event spanning a few days you may want to show events running that day:

    $events = eo_get_events(array(
         'events_end_after'=>'today',
         'events_start_before'=>'today',
      ));
    
    Stephen Harris
Viewing 5 posts - 1 through 5 (of 5 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.