The Events Calendar Pro Widget

Home Forums Calendar Products Events Calendar PRO The Events Calendar Pro Widget

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1001539
    Jako
    Participant

    Hi

    I have multiple events happneing per date and would like to find out how I can get my Calendar widget at the bottom of the page to display only one date as a default?

    Thanks

    #1001725
    George
    Participant

    Hey Jako,

    Do you mean that you only want one event per date to appear? Or all the events of one date, but no other dates than just that one date?

    Either way, this will most likely boil down to requiring some custom code, which we unfortunately cannot help with.

    With that disclaimer out of the way though, I’ll share a quick code example with you to hopefully get you started 🙂 This assumes that you mean that you indeed want all the events of a given day, but only from that day. In other words, for example, this code would only list events happening today September 3, but not ones from Sep. 4, 5, so on.

    You’d achieve this by adding code like the following to your theme’s functions.php file:


    add_filter( 'tribe_events_list_widget_query_args', 'tribe_support_1001539' );

    function tribe_support_1001539( $args ) {
    $args['eventDisplay'] = 'custom';
    $args['start_date'] = strtotime( 'now' );
    $args['end_date'] = strtotime( 'now' );

    return $args;
    }

    I hope that helps!

    — George

    #1002027
    Jako
    Participant

    Thanks George.

    Yes, that is precisely what I mean. I’d like to show all of the events for the current date as a default.

    The above code isn’t working unfortunately. Can you please advise if there is a specific place I should be adding this in the functions.php file.

    Thanks

    Jako

    #1002313
    George
    Participant

    Hey Jako,

    Hm, that code works really well for me, which is curious here – if you paste the entire contents of your functions.php file into a Gist at http://gist.github.com and then share a link to that Gist, I’ll take a look and see if the place you’ve added that code is problematic here at all.

    Thank you for your patience Jako!

    – George

    #1002580
    Jako
    Participant

    Hi George

    Sure, you can find it here. I have added it right at the bottom.

    https://gist.github.com/anonymous/98722e5bb735366fdbd6#file-gistfile1-txt

    Thanks for your help

    Jako

    #1002581
    Jako
    Participant

    Please let me know if you can open the link, as it isn’t displaying when I submit my reply.

    https://gist.github.com/anonymous/98722e5bb735366fdbd6#file-gistfile1-txt

    Thanks

    • This reply was modified 10 years, 8 months ago by Jako.
    #1002966
    George
    Participant

    Thanks for the code @Jako, and for your patience with my delayed reply over the three-day weekend here in the US – I’m curious about this because your file and code both look fine to me, but this works well for me on my testing site…

    One thing worth trying is to modify the code so that, where you see me use this code:
    strtotime( 'now' );

    You replace those instances with this:
    new DateTime();

    Try doing that and see if that helps at all! e.g.:


    add_filter( 'tribe_events_list_widget_query_args', 'tribe_support_1001539' );

    function tribe_support_1001539( $args ) {
    $args['eventDisplay'] = 'custom';
    $args['start_date'] = new DateTime();
    $args['end_date'] = new DateTime();

    return $args;
    }

    I’m sorry that this hasn’t worked immediately for you thus far, and am sorry that I don’t quite know why. Hopefully this change helps!

    — George

    #1003604
    Jako
    Participant

    Hi George

    I have inserted the updated code but still no luck unfortunately.

    Just in case I might have been unclear… When a user lands on the site and scrolls all the way down to the bottom of the page, I’d like for only that specific days’ events to appear in the Events Calendar widget. This works like a charm when a date is selected but I’d like it to appear as a default.

    Let me know if you can think of another way to get around this.

    Thanks

    Jako

    #1004251
    George
    Participant

    Damn, I’m really sorry about this continuing to not work for you @Jako!

    Your notes here are exactly what my code snippet achieves for me:

    When a user lands on the site and scrolls all the way down to the bottom of the page, I’d like for only that specific days’ events to appear in the Events Calendar widget.

    Your functions.php file looks fine to me, so my suspicion is that the Date parameters I’m adding via the filter aren’t working correctly based on your server configuration or something. This was why I recommended new DateTime() instead of strtotime( ‘now’ ) originally, but if that is not helping, the only other alternative worth trying that I can think of is this one:

    strtotime( current_time( 'Y-m-d' ) )

    So, in other words:


    add_filter( 'tribe_events_list_widget_query_args', 'tribe_support_1001539' );

    function tribe_support_1001539( $args ) {
    $args['eventDisplay'] = 'custom';
    $args['start_date'] = strtotime( current_time( 'Y-m-d' ) );
    $args['end_date'] = strtotime( current_time( 'Y-m-d' ) );

    return $args;
    }

    If making this simple change alone does not help, then I’m curious – what is your site’s “Timezone” setting in Settings > General in your wp-admin? If it’s a “named” timezone, like “New York”, can you try setting it to a “numerical” equivalent, e.g. “UTC-4” instead? This may make a difference – if not, then you can set it back to the named timezone without issue.

    Thank you so much for your patience here! I’m sorry about how long this has dragged out but cannot figure out the cause – this code snippet worked on my original testing site and I just added it to another testing site and it works well there, too.

    Sincerely,
    George

    #1008925
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘The Events Calendar Pro Widget’ is closed to new replies.