• Resolved 000000000

    (@pealo86)


    I’m trying to display only one event on a section of my site using the following code:

    <div id="event-lead">
    	<?php
    		$args = array( 'include' => 78 );
    
    		$events = tribe_get_events( $args );
    	?>
    
    	<?php foreach ( $events as $post ) : setup_postdata( $post ); ?>	
    
    		<?php if (has_post_thumbnail()) : ?>
    			<figure class="grid_4">
    				<a href="<?php the_permalink(); ?>">
    					<img src="<?php echo getPostThumbnailUrl('event-lead'); ?>" alt="<?php the_title(); ?>" />
    				</a>
    			</figure>
    		<?php endif; ?>
    
    		<div class="grid_8 content">
    
    			<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
    			<ul class="meta meta-event">
    				<?php echo tribe_events_event_schedule_details( $event_id, '<li>', '</li>'); ?>
    				<?php if (tribe_get_venue()) : ?>
    					<?php if (tribe_get_venue() || tribe_get_venue()) : ?>
    						<li><?php echo tribe_get_venue(); ?>, <?php echo tribe_get_city(); ?></li>
    					<?php endif; ?>
    				<?php endif; ?>
    			</ul>
    
    			<p><?php echo tribe_events_get_the_excerpt(); ?></p>
    			<a class="button button-01" href="<?php the_permalink(); ?>">Read More</a>
    
    		</div>
    
    	<?php endforeach; ?>
    	<?php wp_reset_postdata(); ?>
    
    </div>

    But instead of only displaying the event with an ID of 78, it displays all my events.

    Am I doing something wrong? This doesn’t appear to work in the same way as get_posts(), because I’ve tried doing a similar thing by including a *page* of a specific ID and that worked fine?

    https://www.ads-software.com/plugins/the-events-calendar/

Viewing 1 replies (of 1 total)
  • Hi @pealo86,

    Could you please check whether it is working fine for you or not if you change the code as following?

    Before Editing:

    <?php
    		$args = array( 'include' => 78 );
    
    		$events = tribe_get_events( $args );
    	?>

    After Editing:

    <?php
    		$args = array( 'post_type' => 'tribe_events', 'include' => 78 );
    
    		$events = get_posts( $args );
    	?>

    Best Regards,
    Vinod Dalvi

Viewing 1 replies (of 1 total)
  • The topic ‘tribe_get_events() include / exclude not working’ is closed to new replies.