Support » Plugin: Events Manager - Calendar, Bookings, Tickets, and more! » Any way to make "scope" = "the next 30 days" w/ custom query?

  • Hello there!

    I am using the following code to create a custom list of events sorted by category:

    <h4>Weekly Groups</h4>
    				<?php
    				if (class_exists('EM_Events')) {
    					echo EM_Events::output( array('category'=>2,'limit'=>100,'scope'=>'future','orderby'=>'start_date,time') );
    				}
    				 ?>
    				 <h4>Events</h4>
    				 <?php
    				 if (class_exists('EM_Events')) {
    				 	echo EM_Events::output( array('category'=>3,'limit'=>100,'scope'=>'future','orderby'=>'start_date,time') );
    				 }
    				  ?>

    This works great. However, it shows ALL the future events. Is there anyway to limit it to say “the next X number of days”? or “this month only”?

    I have read in your documentation on scope (http://wp-events-plugin.com/documentation/event-search-attributes/) that you can do the following:

    Choose the time frame of events to show. Accepted values are “future”, “past” or “all” events. Additionally you can supply dates (in format of YYYY-MM-DD), either single for events on a specific date or two dates seperated by a comma (e.g. 2010-12-25,2010-12-31) for events ocurring between these dates. Default Value: future

    I am still learning PHP, but I am guessing that the best way to do this would be to write a query to define a variable as the date using php, and then plug the variables into the argument.

    That said, it’d be very cool if there was a way to do this built in!

    I will be messing with it this afternoon, and will post if I find a solution before I hear from anyone who might have done this before- thanks in advance! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    there’s a few new scopes in version 4. you’ve reminded me to update them, but for now I can tell you the you also have month,this-month,today, tomorrow and a few more.

    but if you want X days, then you’re best off just doing something like

    date('Y-m-d',current_time('timestamp')).date(',Y-m-d',current_time('timestamp')+60*60*24*$xdays):

    Thread Starter jolaedana

    (@jolaedana)

    Thanks Marcus! I had to mess around for a bit to figure out how to pass that to the Event Manager call, but it works like a charm. For anyone else attempting to do the same, here is my code. This outputs events in category 2, within the next 7 days:

    <?php
    				if (class_exists('EM_Events')) {
    				$scopedates = date('Y-m-d',current_time('timestamp')).date(',Y-m-d',current_time('timestamp')+60*60*24*7);
    				$args = array(
    					'orderby' => get_option('dbem_events_default_orderby'),
    					'order' => get_option('dbem_events_default_order'),
    					'scope' => $scopedates,
    					'category' => 2
    				);
    							echo EM_Events::output( $args );							}
    				 ?>

    Thank you! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Any way to make "scope" = "the next 30 days" w/ custom query?’ is closed to new replies.