• Resolved andyruw

    (@andyruw)


    Hi.

    I love the plugin and have used it many times.

    I’m just having a problem with using relative PHP dates in the loop, within a template.

    This is code that I have used many times before, but for some reason I can’t get it to work on this occasion. I’m basically trying to find all the events for each month. So i use:

    ‘event_start_after’ => ‘first day of august’,
    ‘event_start_before’ => ‘last day of august’,

    in the $args for the loop. Usually this works fine, but all of the events are in every month.

    Can you see anything wrong in the code?

    <?php
    $args = array(
    	'order'=> 'ASC',
    	'orderby' => 'eventstart',
    	'post_type' => 'event',
    	'event_start_after' => 'first day of august',
    	'event_start_before' => 'last day of august',
    	'showpastevents' => true
    );
    $the_query = new WP_Query( $args ); ?>
    <div class="cal_dates">
    <?php if ( $the_query->have_posts()) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <!-- LOOP CONTINUES -->

    https://wordpress.org/plugins/event-organiser/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Stephen Harris

    (@stephenharris)

    “first/last day of [month]” is supported only be PHP5.3+ I believe, so could that explain the issue? Have you tried with absolute date?

    There seems to be nothing with the $args statement. But will get all event (dates) which start in August (regardless of whether that occurrence ends in September, say).

    Thread Starter andyruw

    (@andyruw)

    Thanks Steven

    You could’ve been right. I found another way in the end to get the first and last dates of each month.

    $jan_first = date('d-m-Y', mktime(0, 0, 0, date("m", strtotime("January")), 1, date("Y",strtotime("January"))));
    $jan_last = date('d-m-Y', mktime(-1, 0, 0, date("m", strtotime("February")), 1, date("Y")));

    Just glad I got it working.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Having Problems with Relative Dates’ is closed to new replies.