[Plugin: The Events Calendar] Showing past evens in WP loop
-
I’m using the following arguments in a query:
$args = array( 'post_type' => 'tribe_events', 'posts_per_page' => -1, 'orderby' => 'title' ); query_posts($args);
However it is only showing future events, not those that have passed.
Is there a way to simply pull in all events rather than the future ones?
-
I’ve asked right the same thing…let’s hope together! π
I’m asking the same thing too.
My query to get this is :
$events = new WP_Query(); $events->query('post_type=tribe_events&meta_key=_EventStartDate&posts_per_page=-1&eventDisplay=all&orderby=_EventStartDate&order=DESC');
However the order just doesnt seem to be working. Wonder if any of the dev’s know how to overwrite their query?
Looking at a var_dump of $events I can see the query being run, But it does not change to DESC at all.
Is this a bug?
Wow, lots of requests for this – interestingly enough we hadn’t heard really any requests for this prior to this month, but in my rounds on the forum today I’ve counted no fewer than 3.
Let me get Paul, our developer on this plugin who is far more knowledgeable on the code side than I, to take a look at Stuart’s last note and comment directly. Stay tuned here, guys, and thanks for your patience so far.
Hey all,
You should use tribe_get_events when using event specific args like eventDisplay. Here is an example of a query getting past events: https://gist.github.com/3427287
I hope that helps but let me know if you guys need anything else!
Cheers,
JonahFYI, you cannot use our plugins arguments in WP_Query.
Hi jonahcoyote, Your code is pretty much a carbon copy of what I have made barring the “past” being add, I need all events and ordered by date. Showing the latest at the top, The oldest at the bottom.
Hi stuart@koodoocreative.co.uk,
As I said you cannot use the eventDisplay arg along with WP_Query so that’s why what you’re trying to do is not working. You need to use tribe_get_events instead and the code example I posted gives you a sample of how to do this. Does that make sense?
– Jonah
This is a great plugin but my mind is boggled as to why we can’t treat Events posts as we would any normal post or custom post?
Hi jonahcoyote. Looking at your “example” code. There are no params which are going to help me achieve what I would like. Which is order the posts by date ASC or DESC? Can you explain this further?
I also agree with pealo86, why cant this plugin use the WP Query. I have mine working with WP Query, just the order is not working. However if there is a justifiable reason why you have to use tribe_get_events then I will revert back to it and can I just say I am dissapointed by the support for this plugin. I understand that this is something that wasnt initially included in the release, But the fact that myself and others are still asking weeks nearly months later doesnt bode well…
Thanks
@pealo86 – event posts can and treated like normal custom posts. How are they not? You can use WP_Query but you cannot use certain plugin specific arguments (eventDisplay for example) in the query.
@stuart – I think the reason this is not working is that it doesn’t look like there’s an easy way to orderby a meta_key that contains date values… It should be possible but I would suggest digging around a little on Google to see if you can find some examples. Using the stock WP_Query arguments, it doesn’t seem like you can accomplish this.
I hope that helps but let me know if you need anything else.
– Jonah
Me posting this very thread would suggest how Events posts are handled differently to ordinary posts or custom posts. E.g. I cannot work with them using query_posts if the event has already passed.
Also there’s this:
http://wordpress.org/support/topic/plugin-the-events-calendar-cannot-change-order-of-posts-in-query_postsAnd this:
http://wordpress.org/support/topic/plugin-the-events-calendar-trouble-echoing-certain-meta-valuesAs I say, a great plugin, but it would make more sense if I could just handle the posts like any other.
Hi @pealo86 did you manage to solve this? I’ve now got my events order by EventStartDate after using the sort_query_posts_by plugin. However it is now ordering it by the month in descending order (A-Z).
Hi guys, I think Rob and Jonah have already covered a lot here but just to pick up on the idea that you can’t query events which have already past, I don’t find this to be true.
This code for instance http://pastebin.com/s8pHSik7 returns events from last month if I run it on my test setup.
TribeEvents::POSTTYPE is just a class constant – ultimately you are still passing a string (‘tribe_events’) and the effect should be the same.
- The topic ‘[Plugin: The Events Calendar] Showing past evens in WP loop’ is closed to new replies.