其实在你的single-event.php
内容循环中的文件。将此循环添加到您希望扬声器信息显示的位置。
$event_title = get_the_title(); // This is the title of the current single event page we are on.
$args = array(
\'meta_key\' => \'event_name\', // the name of your custom field
\'meta_value\' => $event_title,
\'post_type\' => \'speakers\',
);
$speakers_query = new WP_Query( $args );
if( $speakers_query->have_posts() ) :
echo \'<ul>\'; // start your section here
while( $speakers_query->have_posts() ) : $speakers_query->the_post();
// echo your speaker content here like name, images, etc.
echo \'<li>\' . get_the_title() . \'</li>\';
endwhile;
echo \'</ul>\'; // end your section here
wp_reset_postdata();
endif;