• Resolved JimGasperini

    (@jimgasperini)


    Is it possible to add parameters to a events list shortcode that results in display of events for a given period starting from whatever day it is that a user views the list? Particularly useful for me would be the coming week.

    I’ve looked through the shortcode documentation and found “month”, which lists everything in the current month, and “next-month” but nothing that comes closer than that.
    Thanks–

Viewing 12 replies - 1 through 12 (of 12 total)
  • You could try checking this thread: https://www.ads-software.com/support/topic/using-scope-for-a-custom-display-list/#post-10856544

    You could also try this snippet:

    add_filter( 'em_object_build_sql_conditions_args', 'custom_add_one_week_scope_filter' );
    
    function custom_add_one_week_scope_filter( $args ) {
    	
    	if( isset( $args['scope'] ) && $args['scope'] == '1-weeks' ) {
    		add_filter( 'em_object_build_sql_conditions', 'custom_add_one_week_scope' );
    	}
    	return $args;
    }
    
    function custom_add_one_week_scope( $conditions ) {
    	$EM_DateTime = new EM_DateTime(); //the time, now, in blog/site timezone
    	
    	$start_date = $EM_DateTime->getDate();
    	$end_date = $EM_DateTime->modify('+7 days')->getDate();
    	
    	$conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE))";
    	if( !get_option('dbem_events_current_are_past') ){
    		$conditions['scope'] .= " OR (event_start_date < CAST('$start_date' AS DATE) AND event_end_date >= CAST('$start_date' AS DATE))";
    	}
    
    	
    	if( !empty($conditions['scope']) ){
    		$conditions['scope'] = '('.$conditions['scope'].')';
    	}
    	
    	return $conditions;
    }

    Then to use it:

    [events_list scope="1-weeks"]<p>#_EVENTLINK will take place at #_LOCATIONLINK on 
    #_EVENTDATES at #_EVENTTIMES</p>[/events_list]
    • This reply was modified 6 years, 3 months ago by Tim Vergara.
    Thread Starter JimGasperini

    (@jimgasperini)

    Thanks! That works, almost – for some reason in testing it shows events for less than a full week – next five days (Nov 9-Nov 13.)

    Where should I tweak it?
    Thanks again

    You already tweaked it (wrongly)… With me it neatly shows this current week, just like the scope is intended to do.
    What did YOU change?

    What exactly do you want the output to be:
    1) All events in the current week (Monday – Sunday), no matter what day today is?
    2) All events in the week surrounding today (if today is Wednesday, the show today until next Tuesday)

    Thread Starter JimGasperini

    (@jimgasperini)

    Well no, I did not tweak the functions.php script. Frankly, I don’t know enough to be able to attempt that.
    I do know how to modify the display in the shortcode, but here is your original shortcode in action:
    https://wp.uusanmateo.org/news-events/event-list/

    One thing I just noticed: when I add a test event on Nov 9, one fewer event displays on Nov 13. Something is apparently limiting the number of events to 10. I will look for some default setting in Events Manager.

    To answer your most recent question, I believe we want #2.
    Thanks again.

    Thread Starter JimGasperini

    (@jimgasperini)

    Aha – there is indeed an Events Manager setting that “will control how many events are shown on one list by default,” set to 10 by default.

    Thanks again for a great script. This should be added as a setting to Events Manager.

    On your shortcode you could add something like:

    [events_list scope="1-weeks" limit="0"] That should dispaly all events without any Limit.

    Hi!

    I have some constant event, what I don’t want to list. Is there any shortcode to hide these events, like ignore_ID=”100,108,258″ ?

    No, you cannot exclude a single post, but you can exclude an event category
    [events_list category=”-1″], where 1 is the Event Category ID.

    So, you can add an event category and assign it to any event you do not want included in the events list.

    Thanks the fast response, the apostrof was incorrect, but I changed to the right one: “”! It works well! ??

    I have an issue with this [events_list] as well as the calendar itself
    The list works well, but it use the plugins CSS and I would like to use the template’s CSS.
    Here is what I want to use: https://tinyurl.com/yauuj7lc
    And here it is the “ugly” list: https://tinyurl.com/yau4v24g

    I didn’t found any settings option to enabele/disable CSS for this.

    @duisterdenhaag Do you have an idea?

    Thanks

    Yes I do.
    Unfortunately, I decided to not help out anymore until my own issues and questions have been answered on the Pro forum. Sorry… ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Possible to list events for the coming week?’ is closed to new replies.