Home › Forums › Calendar Products › Events Calendar PRO › The Events Calendar Pro Widget
- This topic has 9 replies, 3 voices, and was last updated 10 years, 7 months ago by
Support Droid.
-
AuthorPosts
-
September 3, 2015 at 12:40 am #1001539
Jako
ParticipantHi
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
September 3, 2015 at 11:55 am #1001725George
ParticipantHey 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
September 4, 2015 at 4:13 am #1002027Jako
ParticipantThanks 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
September 4, 2015 at 3:40 pm #1002313George
ParticipantHey 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
September 7, 2015 at 5:39 am #1002580Jako
ParticipantHi 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
September 7, 2015 at 5:40 am #1002581Jako
ParticipantPlease 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.
September 8, 2015 at 9:28 am #1002966George
ParticipantThanks 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
September 10, 2015 at 4:54 am #1003604Jako
ParticipantHi 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
September 11, 2015 at 8:03 am #1004251George
ParticipantDamn, 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,
GeorgeSeptember 26, 2015 at 7:05 am #1008925Support Droid
KeymasterThis 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. -
This reply was modified 10 years, 8 months ago by
-
AuthorPosts
- The topic ‘The Events Calendar Pro Widget’ is closed to new replies.
