我确实使用tribe\\u get\\u events()实现了这一点,如下所示:
function webinar_list_shortcode($atts) {
global $post;
// Defaults
extract( shortcode_atts ( array (
\'numposts\' => \'5\',
\'status\' => \'upcoming\',
\'eventcat\' => \'\'
),
$atts
));
$options = array(
\'eventDisplay\'=>$status,
\'posts_per_page\'=>$numposts,
\'tax_query\'=> array(
array(
\'taxonomy\' => \'tribe_events_cat\',
\'field\' => \'slug\',
\'terms\' => $eventcat
)
)
);
// query is made
$events = tribe_get_events( $options );
// Reset and setup variables
$output = \'\';
$temp_title = \'\';
$temp_link = \'\';
$temp_ex = \'\';
$temp_content = \'\';
$temp_thumb = \'\';
$temp_id = \'\';
// the loop
foreach($events as $post) {
setup_postdata($post);
$temp_id = $post->ID;
$temp_title = the_title(\'\',\'\',false);
$temp_link = get_permalink($post->ID);
$temp_content = get_the_content($post->ID);
$temp_date = tribe_get_start_date( $post->ID, true, \'l, F j, Y\' );
$temp_speaker = get_field(\'speaker\');
//$temp_ex = get_the_excerpt();
if ( has_post_thumbnail() ) {
$temp_thumb = get_the_post_thumbnail($post->ID, array(200,200));
} else {
$temp_thumb = "";
}
// output all findings -
$output .= "
<div class=\'et_pb_row webinar-row clearfix\'>
<div class=\'et_pb_column et_pb_column_1_4\'>
$temp_thumb
</div>
<div class=\'et_pb_column et_pb_column_3_4\'>
<div class=\'post-$temp_id\' id=\'post-$temp_id\'>
<h3 class=\'webinar-time\'>
$temp_date
</h3><!--BEGIN .entry-content-->
<div class=\'webinar-content\'>
<p><span class=\'purple-text\'>Event: </span>$temp_title</p>
<p><span class=\'purple-text\'>Speaker: </span>$temp_speaker</p>
<a href=\'$temp_link\' class=\'button-details\'>View Event Details<span class=\'et-icon\'></span></a>
</div><!--END .entry-content-->
</div><!--END .hentry-->
</div></div>";
}
wp_reset_query();
return $output;
}