Home › Forums › Calendar Products › Events Calendar PRO › List Specific Events On A Page
- This topic has 6 replies, 2 voices, and was last updated 8 years, 11 months ago by Barry.
-
AuthorPosts
-
June 11, 2015 at 1:15 pm #968881Chris ChungParticipant
I have a page where I want to list event title and dates of specific categories.
So far I have it showing the titles of all events. I’m trying to figure out how to specify the category,
Then I will worry about posting the date field. Thanks!Here is what I have so far:
<?php $args = array( 'post_type'=> 'tribe_events'); $catposts = get_posts($args); foreach($catposts as $post) : ?> <article> <p> <?php echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>'; ?> </p> </article>
June 11, 2015 at 1:46 pm #968885Chris ChungParticipantAttempting:
<?php $cat = 75; $args = array( 'post_type'=> 'tribe_events', 'category__in' => array($cat)); $posts = get_posts($args); if ($posts) { foreach($posts as $post) { setup_postdata($catposts); ?> <article> <p> <?php echo '<a href="' . get_permalink() . '">' . get_the_title() . '</a>'; ?> </p> </article> <?php } } ?>
June 11, 2015 at 3:40 pm #968906BarryMemberHi there!
I’d be happy to point you in the right direction if I can – but I do want to note first of all that custom code is typically not something we can offer a great deal of support for.
With that out of the way, it’s worth noting that events do not use the same categories as blog posts – they use a separate, event-specific type of category. Here’s a couple of things you can try:
- Switch to tribe_get_events() instead of get_posts()
- If you use this function, you don’t need to specify the post type
- You may wish to pass a tribe_events_cat argument in place of category__in
- Additionally, depending on the sort of results you are hoping for, you may wish to provide an eventDisplay argument set to list
Last but not least, be sure to check out this helpful knowledgebase article:
heeventscalendar.com/knowledgebase/using-tribe_get_events
Good luck!
June 12, 2015 at 8:00 am #969056Chris ChungParticipantThanks a bunch Barry! That page you linked is what I was looking for.
Now I just need to find the date field and post that as well.June 12, 2015 at 11:14 am #969163BarryMemberCheck out tribe_get_start_date() 🙂
June 12, 2015 at 11:45 am #969167Chris ChungParticipantThanks, already got it with this:
$date = new DateTime($event->post_date); echo $date->format('l F j , Y');
June 12, 2015 at 12:35 pm #969173BarryMemberAh, ok – if its the publication date you want for the event that probably isn’t a bad way to go.
Glad you’re all sorted 🙂
-
AuthorPosts
- The topic ‘List Specific Events On A Page’ is closed to new replies.