Recently Published Events -sidebar listing

Home Forums Calendar Products Events Calendar PRO Recently Published Events -sidebar listing

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #119862
    webster
    Participant

    Hello,
    I working on building a sidebar events list that displays the new or recently published
    events.

    What is the proper custom post type to use?

    #120133
    Brook
    Participant

    Howdy webster,

    We use the constant TribeEvents::POSTTYPE throughout our code to refer to the tribe events post_type. You could also just use the string 'tribe_events' since it is doubtful that constant will ever change in a future version.

    You might find the function tribe_get_events() helpful. It makes it much easier to select events by a date range, instead of by the date they were posted. If you need a WP_Query object returned, set the second (optional) argument in tribe_get_events to true.

    Does that make sense? Will that work for you? Please let me know. Cheers!

    – Brook

    #120897
    webster
    Participant

    Thanks Brook!
    tribe_get_events(); looks helpful, I’ll look into that for other snippets.
    Here’s what I ended up with for the sidebar code:

    <!– Recent Posts – Tribe Events –>

    • <h3>Hot off the press</h3><?php $args = array(
      ‘post_type’ => ‘tribe_events’, // tribe events cpt
      ‘posts_per_page’ => 4,
      ‘offset’ => 0,
      ‘orderby’ => ‘post_date’,
      ‘order’ => ‘DESC’,
      ‘post_status’ => ‘publish’,
      ‘suppress_filters’ => true );
      ?>

      <ul class=”rec-events”>
      <?php
      $recposts = get_posts( $args );
      foreach ( $recposts as $post ) : setup_postdata( $post ); ?>

    • “><?php the_title(); ?>
    • <?php endforeach;
      wp_reset_postdata();?>

      <!– / rec-events –>

    #121079
    Brook
    Participant

    Excellent! Glad to here that helped sir. And thank you for sharing your solution, it will definitely help other forum members. If you have any more issues in the future please open a topic and ask away. I am marking this one answered.

    By the way, if you have a minute or two, we would love it if you could write a few words about the plugin here.

    I hope the site development goes smooth. Cheers!

    – Brook

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Recently Published Events -sidebar listing’ is closed to new replies.