Listing Events For One Year – Almost There

Home Forums Calendar Products Events Calendar PRO Listing Events For One Year – Almost There

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #945932
    Scott
    Participant

    I’ve been struggling (I’m a newb) on how to have The Events Calendar print a list of all events within a specified year. I researched this need heavily online and I’m surprised that there’s limited info on the subject. The list is simple really. It just needs to be a linked title that sends the user to the actual event page.

    My approach was to create a custom [shortcode] in functions.php so I could place the list on any WordPress page or post that I need.

    The custom shortcode PHP is the following.

    // Setting up custom function called yearList
    add_shortcode(‘yearList’, ‘yearList’);
    function yearList()
    {

    // Ensure the global $post variable is in scope
    global $post;

    // Retrieve all events desired year. Only eight printed out of 80.
    $events = tribe_get_events( array(
    ‘eventDisplay’ => ‘custom’,
    ‘start_date’ => ‘2014-01-01 00:01’,
    ‘end_date’ => ‘2014-12-31 23:59’
    ) );

    // Loop through the events: set up each one as
    // the current post then use template tags to
    // display the title and content
    foreach ( $events as $post ) {
    setup_postdata( $post );

    // prints the title for each event.
    echo ‘<br><br>’;
    // WRONG WRONG – This is below is what’s throwing me.
    echo ‘” title=”<?php the_title() ?>”>‘;
    //the_title();
    // echo tribe_get_start_date(); This shows the start date and time after the event title I slept this for now.

    }
    }

    I have two questions.

    • Why would the loop only show nine titles when I have over 80 stamped for 2014?
    • How can make each line be a link to The Calendar Events actual event page? I’ve tried to employ this with no luck.
    #946060
    Brian
    Member

    Hi,

    Glad you are getting closer I can help out here.

    For the loop only showing 9 titles try adding this to the tribe_get_events array:

    'post_post_page' = > -1

    To link a title you can try using WordPress’s get_permalink:

    http://codex.wordpress.org/Function_Reference/get_permalink

    Let me know if that helps.

    Thanks

    #959518
    Brian
    Member

    Since I haven’t heard back from you here, I’m going to go ahead and close out this thread. Feel free to start a new thread if you have further issues. Thanks! 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Listing Events For One Year – Almost There’ is closed to new replies.