• Resolved fersamp

    (@fersamp)


    Hi guys,
    I have this query that extracts events in my custom period:

    select * from SqE_em_events  where
    				(date( SqE_em_events.event_end_date) = curdate()
    				and time(SqE_em_events.event_end_time) > '06:00:00'
    				and time(SqE_em_events.event_end_time) > curtime())
    			or  (date(SqE_em_events.event_end_date) = curdate() + interval 1 day
    				and (time(SqE_em_events.event_end_time) <= '06:00:00'))
    			or  (date(SqE_em_events.event_start_date) = curdate()
    				and time(SqE_em_events.event_start_time) > '06:00:00'
    				and time(SqE_em_events.event_end_time) > curtime())
    			or  (date(SqE_em_events.event_end_date) = curdate()
    				and time(SqE_em_events.event_end_time) <= '06:00:00'
    				and time(SqE_em_events.event_end_time) > curtime())

    I tried to add custom filter into my_functions.php file in my child theme, but with no success ( http://wp-events-plugin.com/tutorials/create-your-own-event-scope/)

    My aim is create a custom shortcode to filter events in events list with this “custom TODAY”:
    Can some one help me to do this filter?

    Thank you guys.

    https://ww.wp.xz.cn/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    The code in the tutorial should pretty much do what you want out-of-the-box. If it’s looking too far ahead, try changing the strtotime("+1 day) part to something else like strtotime("+12 hours) etc.

    Thread Starter fersamp

    (@fersamp)

    Hi caimmin_nwl,

    I tried to use this query condition, but it doesn’t work:

    $today_date = date('Y-m-d',current_time('timestamp'));
    $now_time = date('H-i-s',current_time('timestamp'));
    $tomorrow_date = date('Y-m-d',strtotime("+1 day", current_time('timestamp')));
    
    $conditions['scope'] = " (event_start_date = CAST('$today_date' AS DATE) and EXTRACT(HOUR FROM event_start_time) > 6 ) OR (event_start_date = CAST('$tomorrow_date' AS DATE) and EXTRACT(HOUR FROM event_start_time) < 6 )";
    $conditions['scope'] = " (event_end_date = CAST('$today_date' AS DATE) and EXTRACT(HOUR FROM event_end_time) > 6 ) and (event_end_time > CAST('$now_time' AS DATE)) ";
    $conditions['scope'] .= " OR (event_end_date = CAST('$tomorrow_date' AS DATE) and EXTRACT(HOUR FROM event_end_time) <= 6 )";
    $conditions['scope'] .= " OR (event_start_date = CAST('$today_date' AS DATE) and EXTRACT(HOUR FROM event_start_time) > 6 and (event_end_time > CAST('$now_time' AS DATE)))";
    $conditions['scope'] .= " OR ((event_end_date = CAST('$today_date' AS DATE) and EXTRACT(HOUR FROM event_end_time) <= 6 ) and (event_end_time > CAST('$now_time' AS DATE)))";

    I think that is a syntax problem, what is the query language that Events Manager uses?

    For example,
    is it correct date and time comparision with current date/time as I did?
    And a comparision with a fixed hour ( 06:00:00 )?
    ( in the guide I see only a date range using a BETWEEN, so I don’t know ho to do the other comparison)
    Thank You again

    I think you are making this too complicated. Did you try the suggestion in my previous reply?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom Today Filter’ is closed to new replies.