Home › Forums › Calendar Products › Events Calendar PRO › Show Older Events on Main Page
- This topic has 7 replies, 2 voices, and was last updated 11 years, 2 months ago by
Barry.
-
AuthorPosts
-
January 14, 2015 at 10:26 am #932823
mlivesay
ParticipantI asked this question in the WordPress.org forum (https://wordpress.org/support/topic/show-past-events-in-agenda-view?replies=3) but the answer did not help me.
We want to show events up to 7 days prior to the current date.
So if today is 1-14-2015 then we would like to show events at the top of the homepage which occurred as long ago as 1-7-2015.
People usually come to our site to see the results links from a previous race up to 7 days after it occurred.
Someone mentioned modifying the tribe_pre_post_query
There is no such thing as tribe_pre_get_posts.
There is tribe_events_pre_get_posts and simply pre_get_postsI see 3 cases in the pre_get_posts function for week, photo and all.
I do not see anything in there where I would modify the date…?
January 15, 2015 at 7:50 am #933280Barry
MemberHi mlivesay,
I have to note immediately that this is very much a customization task and the amount of assistance we can provide you with is therefore fairly limited – even so I’d be happy to moot a few ideas that might help 🙂
We want to show events up to 7 days prior to the current date.
So if today is 1-14-2015 then we would like to show events at the top of the homepage which occurred as long ago as 1-7-2015.
So is this only to occur on the main events page rather than all event views?
People usually come to our site to see the results links from a previous race up to 7 days after it occurred.
Given that, am I right in thinking that you may indeed wish to style things differently in order to highlight that these are past results? If so, perhaps and easier and more suitable avenue is to customize the relevant template and add a snippet or two to pull the past week’s results in there – using our tribe_get_events() function perhaps – and you can then format them however you would like.
Would that sort of approach work for you?
Someone mentioned modifying the tribe_pre_post_query
There is no such thing as tribe_pre_get_posts.
There is tribe_events_pre_get_posts and simply pre_get_postsI see 3 cases in the pre_get_posts function for week, photo and all.
I do not see anything in there where I would modify the date…?
So I think that was just a typo and tribe_events_pre_get_posts is indeed the action that was being referred to. This can be viewed as a more specialized form of WordPress’s own pre_get_posts action – in that you know it will only fires for queries that relate to events.
You can use this action to modify the date range by following this sort of pattern:
add_action( 'tribe_events_pre_get_posts', 'alter_event_date_range' ); function alter_event_date_range() { $one_week_ago = date( 'Y-m-d', strtotime( '-1 week' ) ); $query->set( 'start_date', date( 'Y-m-d', $one_week_ago ); }That’s not a complete example, of course, because you will not always want to modify the date in that way – but it shows the basic form.
January 20, 2015 at 7:34 am #935188mlivesay
ParticipantAlright,
1) Could you point me to more complete documentation on your “Loop”? I like the idea of adding an additional loop only for the past events, so I don’t want to modify the default loop.
2) I think modifying the template is the best way to proceed; however, I’ve got a pretty big problem.
We’re using WP MultiSite, I’ve shut off all Caching, but no modifications I make to the “views” templates make any effect on how the pages render on the website.
I can even DELETE the entire Views folder from both the events-calendar-pro and the the-events-calendar folders and the /events/ page is still rendered correctly…?!
You can see on the code of the page that there is no caching enabled, ultramaxsports.com/okc/events/
Have you encountered this issue before?
Do you know of a fix for it?Thank you in advance for your suggestions.
January 20, 2015 at 8:22 am #935220Barry
MemberHi!
Could you point me to more complete documentation on your “Loop”? I like the idea of adding an additional loop only for the past events, so I don’t want to modify the default loop.
Where we use a regular loop it is not really any different to the WordPress loop itself (except, of course, it is concerned with events and event times rather than blog posts and publication times) and actually it is driven by the very same mechanisms – so we don’t really have any specific documentation of our own on that count.
What I’d note here, though, is that if you use tribe_get_events() to pull in those events, even from within the loop, it should not impact on the main/outer loop at all.
2) I think modifying the template is the best way to proceed; however, I’ve got a pretty big problem.
We’re using WP MultiSite, I’ve shut off all Caching, but no modifications I make to the “views” templates make any effect on how the pages render on the website.
I can even DELETE the entire Views folder from both the events-calendar-pro and the the-events-calendar folders and the /events/ page is still rendered correctly…?!
We do try hard to stick to one issue per topic, so if you are experiencing problems in setting up template overrides I’d respectfully ask you post them in a fresh topic – one of the team will be only too happy to help.
A couple of pointers that might help before you do that, though:
- You can review the correct process for setting up template overrides here – the key thing is to place them in a tribe-events subdirectory within your theme
- If you have no template overrides and have also deleted the views directory from within each of our plugins (incidentally, we recommend you never modify core plugin code) and the event views continue to work it is likely you are still seeing cached content
- Deactivating a caching plugin does not always stop cached content from being served: please refer to the instructions provided by the caching plugin author or seek their help in terms of completely removing caching as you may additionally need to tidy up various other files and directories to stop cached content from being served to visitors
- Remember that some web hosts provide an additional caching layer, above and beyond what is provided by any caching plugin you install
- Once the effects of caching have been fully eliminated, you will have a clear picture of what’s happening, can make your changes and then can carefully re-enable caching when you’re ready
I hope that helps 🙂
January 20, 2015 at 9:45 am #935280mlivesay
ParticipantAwesome! You answered both questions perfectly!
I had no idea someone else had setup the Theme Overrides, so that’s exactly what was going on.
You all have an awesome plugin. Thank you so much for your prompt replies!
Have a great day!
January 20, 2015 at 9:55 am #935285mlivesay
ParticipantAw, Sorry. 🙁 I spoke too soon and need to know one more thing.
For tribe_get_events I see I can order by the date, but how would I make sure to only pull “the past 7 day’s of events”?
Would you recommend I run tribe_get_events and then inside the loop simply choose which events to display based on my own PHP code?
Is there an argument to pull X days prior?
Do you have a list of all arguments, or are they simply the ones specified on the Function page and the same as WordPress get_posts? http://codex.wordpress.org/Template_Tags/get_posts
Thanks again.
January 20, 2015 at 1:22 pm #935361Barry
MemberGreat question – we actually need to bolster our docs in that area but yes, it does indeed respect most or all of the arguments accepted by get_posts().
In addition, you can pass a number of event-specific arguments:
- start_date yyyy-mm-dd hh:mm format (year-month-day hours:minutes, ie 2015-01-20 13:20)
- end_date in yyyy-mm-dd hh:mm format as above
- eventDisplay which may be one of:
- custom (generally recommended for custom work like this)
- list
- past
- month
- week
- photo
- map
So here I’d suggest setting eventDisplay to custom and programmatically determining the correct start_date and end_date for the range of events you wish to fetch 🙂
February 6, 2015 at 9:17 am #940545Barry
MemberHi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!
-
AuthorPosts
- The topic ‘Show Older Events on Main Page’ is closed to new replies.
