Date Range and Mini Calendar Question

Home Forums Calendar Products Events Calendar PRO Date Range and Mini Calendar Question

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #58545
    Patrick Sasser
    Participant

    I have two questions
    1) I’m trying to use a WP Query to select events in a date range. I want to select events from today until the next seven days. Here’s the code that I’m using…

    $current_date = date(‘j M Y’);
    $end_date = date(‘j M Y’, strtotime(‘+7 days’));
    $upcoming = new WP_Query();
    $upcoming->query( array(
    ‘post_type’=> ‘tribe_events’,
    ‘eventDisplay’ => ‘upcoming’,
    ‘posts_per_page’ => -1,
    ‘start_date’=>$current_date,
    ‘end_date’=>$end_date,
    ‘tribe_events_cat’ => ‘Events Area’)
    );
    if ($upcoming->have_posts()) :
    while ($upcoming->have_posts()) :
    $upcoming->the_post();

    //excecute my stuff here

    endwhile;
    endif;

    unfortunately this code is returning events that aren’t occurring in the next seven days. Any thoughts?

    2) The mini calendar is much improved in version three, but upon initial load of the calendar it shows my next 5 upcoming events (because that’s the setting I have chosen in the widget setting). I don’t want it to show the next 5 upcoming events. Instead I want it to only show the events for today’s date. If no events occur on today then I want it to say “No Events Today” is there any way that I can do that?

    #58829
    Barry
    Member

    Hi psasser – it’s important that you create separate threads for separate issues in order to avoid confusion. Can you post your second issue in a new thread?

    #58830
    Barry
    Member

    Unfortunately this code is returning events that aren’t occurring in the next seven days. Any thoughts?

    We can’t do too much when it comes to custom code like this, but some thoughts are:

    * It would be better to use a yyyy-mm-dd format (Y-m-d) for your dates
    * You may prefer to use custom for eventDisplay
    * Remember also that tribe_get_events() accepts and functions like WP_Query but may be better in some circumstances

    #58839
    Patrick Sasser
    Participant

    Thanks so much for the tip and the information. I moved the mini calendar question to a new forum…https://theeventscalendar.com/support/forums/topic/mini-calendar-question/. The Tip you gave about date format being in yyyy-mm-dd worked perfectly and fixed my issue. Thanks so much for the help.

    #58843
    Barry
    Member

    Great! One of the team (possibly me) will be along to address the other thread shortly 🙂

    #979762
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Date Range and Mini Calendar Question’ is closed to new replies.