WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar
Past events (9 posts)

  1. inTOWN
    Member
    Posted 2 years ago #

  2. inTOWN
    Member
    Posted 2 years ago #

    Ah, foundit:

    <?php $loop = new WP_Query( array( 'post_type' => 'tribe_events', 'posts_per_page' => 2, 'orderby' => 'date', 'order' => 'ASC', 'paged', 'eventDisplay' => 'past') ); ?>

  3. berchman
    Member
    Posted 2 years ago #

    What if you wanted to display past events in an unordered list?

  4. berchman
    Member
    Posted 2 years ago #

    I did try this with no luck

    <ul id="past_events">
    <?php $args = array( 'post_type' => 'tribe_events', 'posts_per_page' => 5, 'eventDisplay' => 'past' );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
  5. inTOWN
    Member
    Posted 2 years ago #

    Check this:

  6. berchman
    Member
    Posted 2 years ago #

    Mea Culpa.

    The code I posted does indeed work.
    You just need to make sure you have a past event entered :-P

  7. inTOWN
    Member
    Posted 2 years ago #

    I see my link to pastebin didn't work... let's try again:

  8. inTOWN
    Member
    Posted 2 years ago #

    uh??? Okay try like this:

    <?php
    /**
    * The TEC template for a list of events.  This includes the Past Events and Upcoming Events views
    * as well as those same views filtered to a specific category.
    *
    * You can customize this view by putting a replacement file of the same name (list.php) in the events/ directory of your theme.
    */
    
    // Don't load directly
    if ( !defined('ABSPATH') ) { die('-1'); }
    
    $event = array();
    $tribe_ecp = TribeEvents::instance();
    reset($tribe_ecp->metaTags); // Move pointer to beginning of array.
    foreach($tribe_ecp->metaTags as $tag){
    	$var_name = str_replace('_Event','',$tag);
    	$event[$var_name] = tribe_get_event_meta( $post->ID, $tag, true );
    }
    
    $event = (object) $event; //Easier to work with.
    
    ob_start();
    	post_class($alt_text,$post->ID);
    $class = ob_get_contents();
    ob_end_clean();
    
    ?>
    <div class="upcoming">
    
    <hgroup><div class="icon"><div class="news"></div></div> <h3>Past Events</h3></hgroup>
    
    <?php $loop = new WP_Query( array( 'post_type' => 'tribe_events', 'posts_per_page' => 2, 'orderby' => 'date', 'order' => 'ASC', 'paged', 'eventDisplay' => 'past') ); ?>
      <ul id="list" class="small">
    
      <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
        <?php tribe_is_past($post->ID, 'tribe_is_past', true); ?>
      	<li class="small">
    
        	<a href="<?php the_permalink(); ?>"><?php if ( has_post_thumbnail() ) the_post_thumbnail('small-list-thumbnail'); ?></a>
            <span>
            <h4><?php the_title('<a href="' . tribe_get_event_link() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a>'); ?> </h4>
            <?php echo tribe_get_start_date( null, false, 'd.m.y' ); ?> <br />
            <?php  $venue = tribe_get_venue();  if ( !empty( $venue ) ) : ?><?php echo $venue; ?> <?php endif; ?>
            <?php  $country = tribe_get_country();  if ( !empty( $country ) ) : ?><?php echo $country; ?> <?php endif; ?>
    
            </span>
         </li>
    <?php endwhile; ?>
    </ul>
    
    </div>
  9. bwp
    Member
    Posted 2 years ago #

    Great, inTOWN. First they kill posts with too much code and tell us to use a pastebin, and then they block pastebin links?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic