Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @iceturtle4,

    Just tested the snippet and it works as expected in my local site. It re-orders past events when called via ajax. Checking out your site I see that’s not what you need. Please try adding this snippet to the functions file:

    add_action ('tribe_events_pre_get_posts', 'reorder_events', 100);
    function reorder_events ( $query ){
        if ( ! $query->is_main_query() || ! $query->get( 'eventDisplay' ) ) return;
        $query->set( 'order', 'DESC' ); //other possible value is ASC
    }

    Best,
    Nico

    Thread Starter IceTurtle4

    (@iceturtle4)

    Yes, this did the trick one the events page thank you!

    But on the homepage it seems to be displaying the 3 most recent events, but from oldest up top to most recent at the bottom, and it does not seem to be adding new events.

    Here is the code in the homepage template

    <h3 class="orange">Events</h3>
    					<?php global $post; ?>
    
    					<?php $all_events = tribe_get_events(
    							array(
    								'eventDisplay' => 'upcoming',
    								'posts_per_page' => 3,
    								'tax_query' => array(
    								array(
    									'taxonomy' => 'tribe_events_cat',
    									'field' => 'slug',
    									'terms' => 'featured'
    								)
    							)
    						)
    					);
    					?>
    					<?php if ($all_events) : ?>
    					<?php foreach($all_events as $post) : ?>
    					<?php setup_postdata($post); ?>
    					<div class="post">
    						<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    						<p class="byline"><abbr class="published"><?php echo tribe_get_start_date($post->ID, true, 'M j, Y'); ?></abbr></p>
    					</div>
    					<?php endforeach; ?>
    					<?php else : ?>
    					<div class="post">
    						<p class="noevents">No Upcoming Events</p>
    					</div>
    					<?php endif; ?>
    					<?php wp_reset_query(); ?>
    
    					<p><a href="<?php bloginfo('url'); ?>/events/">More Events</a></p>
    				</div>
    			</div>

    Any ideas – and thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display order of past events’ is closed to new replies.