WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] What other options are there for SCOPE besides future? (5 posts)

  1. debsch
    Member
    Posted 2 years ago #

    Hello - a QUICK question I hope.

    There's 'scope'=>'future'
    but what else?
    Today/tomorrow/next_week/next-week/nextweek??

    I can't find a list anywhere.
    (Have tried a search on the EM website and just come up with create your OWN scope - I just want to know what's there already)

    Thank you!

    http://wordpress.org/extend/plugins/events-manager/

  2. debsch
    Member
    Posted 2 years ago #

    Aha! (I gave up too soon)

    http://wp-events-plugin.com/documentation/event-search-attributes/

    Accepted Arguments : future, past, today, tomorrow, month, next-month, 1-months, 2-months, 3-months, 6-months, 12-months, all

    But no week or fortnight....
    I might be posting a question about that if I can't figure out the 'create your own scope' tutorial.

  3. debsch
    Member
    Posted 2 years ago #

    Great tutorial!

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='nextfortnight' ){
    		$start_date = date('Y-m-d',current_time('timestamp'));
    		$end_date = date('Y-m-d',strtotime("+14 days", current_time('timestamp')));
    		$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE)) OR (event_end_date BETWEEN CAST('$end_date' AS DATE) AND CAST('$start_date' AS DATE))";
    	}
    	return $conditions;
    }

    Then I change 'scope'=>'future' to 'scope'=>'nextfortnight'
    and it shows the events for the next fortnight.
    Fabulous!
    :)

  4. eliasen
    Member
    Posted 2 years ago #

    Where did you add your own filter, Debsch? Looks exactly like what I'm looking for. Thanks in advance.

  5. agelonwl
    Member
    Posted 2 years ago #

    you can add that in your theme functions e.g. functions.php

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic