What a useful reply that is Samuel.
It doesn’t work for me either, I’m trying to use the following code, which works fine in the template, but not when I use it in the widget:
<?php $custom_taxterms = wp_get_object_terms( $post->ID, 'tribe_events_cat', array('fields' => 'ids') );
$args = array(
'post_type' => 'tribe_events',
'post_status' => 'publish',
'posts_per_page' => 3,
'orderby' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'id',
'terms' => $custom_taxterms
)
),
'post__not_in' => array ($post->ID),
);
$related_items = new WP_Query( $args );
if ($related_items->have_posts()) :
echo '<div>';
while ( $related_items->have_posts() ) : $related_items->the_post();
?>
<div>
<h4><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
<h5><meta itemprop="startDate" content="<?php echo tribe_get_start_date( null, false, 'Y-m-d-h:i:s' ); ?>"/><?php echo tribe_get_start_date(); ?></h5>
<p><?php echo excerpt(20); ?></p>
</div>
<?php
endwhile;
echo '</div>';
endif;
wp_reset_postdata();
?>