Home › Forums › Calendar Products › Events Calendar PRO › Annual Archives?
- This topic has 10 replies, 4 voices, and was last updated 11 years, 11 months ago by Rob.
-
AuthorPosts
-
April 30, 2012 at 10:51 am #18440MartyParticipant
Hi there,
I need to create list-style views for given years. Right now the direction I’m considering is creating page templates that execute a specially constructed query. But that seems like a very manual approach and I sense there’s a better way.
For instance, I’d rather do hook into the existing ECP infrastructure, for instance by adding a new parameter:
/events/2011
Which could also apply to categories:
/events/category/free-events/2011/
Any tips on how to approach this? Anything that can get me pointed in the right direction would be appreciated. Thanks!
April 30, 2012 at 5:44 pm #18450JonahParticipantHey Marty,
Good question. I don’t think this is easily achievable with the plugins infrastructure so you’d probably be better off creating the page templates. That’s what I would do if I was building a site that need this. You can easily setup custom queries using WP_Query or tribe_get_events() (https://theeventscalendar.com/support/documentation/the-events-calendar-template-tags-general-functions/#functiontribe_get_events)
It’s not a bad idea though and it might be a good feature in the future. If you’re interested you can add it to out feature request thread here: https://theeventscalendar.com/support/forums/topic/events-calendar-pro-feature-requests/
I hope that helps!
May 2, 2012 at 2:18 pm #18577MartyParticipantHi Jonah, thanks for the response. Can you tell me a bit more about tribe_get_events()? I’m trying this:
'eventDisplay'=>'past',
'start_date'=> '1 Jan 2004',
'end_date'=> '31 Jan 2004',
'posts_per_page'=>-1
But it’s including events all the way up to yesterday. I take it end_date’s not what I need in this case? What’s the correct way to limit a query to events beginning within a certain date range?
Thanks
May 2, 2012 at 4:04 pm #18584JonahParticipantHey Marty,
Try passing in the date in this format instead ‘1/1/2004’ – that should work.
May 4, 2012 at 11:41 am #18700MartyParticipantHi Jonah,
Sorry, that didn’t work for me. I was able to do it (so far so good, at least) using WP_Query with meta_query:
$thisyear = get_post_meta($post->ID, 'year', true);
$nextyear = $thisyear + 1;$args = array(
'post_type' => 'tribe_events',
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => '_EventStartDate',
'meta_query' => array(
array('key' => '_EventStartDate',
'value' => array($thisyear . '-01-01 00:00:00', $nextyear . '-01-01 00:00:00'),
'type' => 'DATETIME',
'compare' => 'BETWEEN'
)));
$the_query = new WP_Query( $args );
May 4, 2012 at 12:13 pm #18712JonahParticipantHmmm, ok try this format: ‘2012-05-03 00:00:00’
Glad you got it working though 🙂
May 21, 2012 at 2:33 pm #19480MartyParticipantHi. I’ve got the page-based solution working and was moving on… and then I came upon this:
http://snipplr.com/view.php?codeview&id=17432It creates year based archives for categories. Which is awesome. It doesn’t automagically work for Events, but might it point the way to something that could work?
Anyone out there fluent in wp_rewrite who could offer an opinion?
May 21, 2012 at 6:27 pm #19490DebraParticipantMarty: I need to do the exact same thing – have a page for year based archives. Do you mind sharing your page based solution code?
Thanks!May 22, 2012 at 12:10 pm #19547RobMemberMarty: mind sharing your solution for the above, so Debra can take advantage of it?
As for the wp_rewrite…I’m not familiar with this myself but I’ll ask the team and if one on our end has an idea here they’ll comment directly.
May 22, 2012 at 7:14 pm #19583DebraParticipantI was able to accomplish what I needed (listing the events by year) by creating a category for each year and then linking to that category listing page. Worked well without any special coding.
I’d still like to see Marty’s solution though in case my client needs anything more involved.
May 23, 2012 at 7:56 am #19609RobMemberAwesome to hear you found a solution here, Debra. If Marty sees this hopefully he can share what his was as well (so you’ve got multiple options available).
-
AuthorPosts
- The topic ‘Annual Archives?’ is closed to new replies.