Home › Forums › Calendar Products › Events Calendar PRO › Homepage customization / including upcoming and past events
- This topic has 33 replies, 6 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
November 11, 2011 at 11:40 am #10979
Adam
MemberOne other addendum I realized I should mention sooner rather than later: my understanding is that getting posts this way produces “static” posts, i.e. they lack pagination. But I did have (and need) this for the homepage so people can click back and see that there is a rich history of events. This was no problem with query_posts, but can I also have that with the $upcoming and $past queries?
November 12, 2011 at 6:05 am #11000John
MemberHi Adam,
The December post isn’t showing up because tribe_get_events is using the system’s default posts_per_page option. You can add ‘posts_per_page’=>-1 to show all upcoming events.
As far as pagination goes, it generally doesn’t work with get_posts. We are hoping to implement a custom pagination solution in an upcoming release.
November 12, 2011 at 2:35 pm #11006Adam
MemberThanks John – but the issue is actually that the upcoming and past events loops show the same events, no difference in the output. (I think I made some tweaks to the code since the time when that was the issue…)
Here is the code:
And here is what shows up:
November 14, 2011 at 10:22 am #11032Adam
MemberHey… guys. My client’s limping along with a broken 1.6.5 site and I REALLY need your help to get 2.0.1 working.
To reiterate where I’m at now, I just need the “full” code (fragments without context are not really helpful) to loop twice through events, once showing upcoming events and once showing past events. As well, I need to be able to display posts from particular categories on various e-newsletter templates.
For the first issue, I tried (as an alternate to what’s in the pastebin link above) copying the entire code from list.php into my home.php page to grab upcoming events, but there it tells me “no upcoming events”. When I go to the regular link for upcoming events though, I do see the correct list.
FYI, I am trying to learn what I can on my own – I found this article very promising, but at the end I still don’t know why my two loops are producing the same results:
http://digwp.com/2011/05/loops/
Five minutes of your undivided attention would be all it takes, I’m sure. I can also be available any time for a quick email or phone exchange. Let me know. I’m really in a corner here. Thanks!
November 14, 2011 at 11:28 am #11053Rob
MemberHey Adam. Thanks for the note. I totally understand your position and am working to get someone on the team to respond today. Just as a heads up, we’re a small shop and I’m the only full-on dedicated support person; John & Jonah help out throughout the week but they are not on full-time so don’t hit every thread every day. Given our setup we’re unfortunately not in a position where we can be providing continuous support at much faster a rate than we do now.
This being said, I do feel your pain and I’ve got this back on John’s plate, & have asked our other developer Jonah to take a look as well. (I’d offer my services as well but am unfortunately not a developer). I know Jonah is on today so if he can add anything else here you can expect a response this afternoon…otherwise I’ll need to circle up with John which likely won’t be until tomorrow.
November 14, 2011 at 11:32 am #11054Adam
MemberThanks Rob for the quick reply. I totally get that you guys have limited resources and definitely appreciate the help you are able to provide. I’ll sit tight and wait for some more assistance.
Hopefully down the road much of this can be included in the documentation – along with nice clear example PHP code… assuming that my situation is just a matter of learning “how to” and isn’t some kind of bug or technical problem (hope not!).
Again, many thanks and looking forward to getting this sorted out.
November 14, 2011 at 12:28 pm #11061Jonah
ParticipantHi Adam,
It looks like the code you were using from Pastebin above had bad single quotes that was not properly passing the upcoming and past arguments to the query. If you fix the single quotes, it works. See here: http://pastebin.com/GhbcrssP
Let me know if you need anything else.
Regards,
JonahNovember 14, 2011 at 3:16 pm #11075Adam
MemberThanks a million Jonah! Figures it would be something totally minor like that. D’OH!
That leaves only one roadblock remaining for me: can you advise on how to query for events that are in particular categories? I’ve defined “featured” and “mailout” categories, for example – both used in custom templates I created for newsletter mailouts. In the previous version of the plugin I could just query_posts for posts checked with these categories. How can I specify that now?
November 14, 2011 at 4:43 pm #11081Rob
MemberExcellent to hear Jonah was able to help you out here, Adam. I’ll get him to nail down this final bit for you either tonight or tomorrow morning, so we’ve got it ironed out.
November 14, 2011 at 4:43 pm #11082Rob
MemberExcellent to hear Jonah was able to help you out here, Adam. I’ll get him to nail down this final bit for you either tonight or tomorrow morning, so we’ve got it ironed out.
November 14, 2011 at 9:06 pm #11092Jonah
ParticipantHey Adam,
You’re welcome!
Since ECP and TEC use taxonomies for categories you’ll need to include taxonomy arguments in your query like so:
$upcoming = tribe_get_events( array('eventDisplay'=>'upcoming', 'posts_per_page'=>-1, 'tax_query'=>array(array('taxonomy'=>'tribe_events_cat','field'=>'id','terms'=>3))));
Where ‘terms’ is the ID of your category (really your taxonomy). You can also change ‘field’ to slug and use the slug of the category instead.
More details on querying by taxonomies is here: http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
That should do it for you but let me know if you need any other help with this.
Regards,
JonahNovember 16, 2011 at 7:11 am #11157Adam
MemberThanks again Jonah! However, I’m trying to utilize your code and it simply returns all upcoming events, not just the ones in (in this case) the “selected” category. I tried:
$upcoming = tribe_get_events( array('eventDisplay'=>'upcoming', 'posts_per_page'=>-1, 'tax_query'=>array(array('taxonomy'=>'tribe_events_cat','field'=>'id','terms'=>5))));
Where the category is #5.
I also tried this based on the codex article, using “array (‘name-of-category’)”:
$upcoming = tribe_get_events( array('eventDisplay'=>'upcoming', 'posts_per_page'=>-1, 'tax_query'=>array(array('taxonomy'=>'tribe_events_cat','field'=>'id','terms'=>array ('selected')))));
But that provides no results at all.
Just for fun, here’s a link to the entire code: http://pastebin.com/zRk8YKU8
And the page in question: http://designerblowout.ca/mailout-selected
Hope you can point me toward my error! 8^)
November 16, 2011 at 7:21 am #11158Jonah
ParticipantHey Adam,
Where’s your query for past events like you had before? You don’t have it in the code and that’s why you’re not seeing past events anymore. You’re only querying your upcoming events. The example I gave was just for your upcoming events but you’ll want to do the same thing for listing your past events.
Upcoming:
$upcoming = tribe_get_events( array('eventDisplay'=>'upcoming', 'posts_per_page'=>-1, 'tax_query'=>array(array('taxonomy'=>'tribe_events_cat','field'=>'id','terms'=>3))));
Past:
$past = tribe_get_events( array('eventDisplay'=>'past', 'posts_per_page'=>-1, 'tax_query'=>array(array('taxonomy'=>'tribe_events_cat','field'=>'id','terms'=>4))));
Make sense?
Regards,
JonahNovember 16, 2011 at 9:02 am #11164Rob
MemberThanks Jonah!
November 16, 2011 at 9:10 am #11168Adam
MemberSo sorry Jonah, looks like your code is indeed working like a charm! I jumped to a wrong conclusion when I was checking the page. It’s fine! Thanks again!
(BTW I do have the query in there on line 66… this is for a different page, a newsletter that only lists upcoming events.)
All the best!
-
AuthorPosts
- The topic ‘Homepage customization / including upcoming and past events’ is closed to new replies.
