正如@helenhousandi所说,为什么不使用WP\\u查询,请尝试以下操作:
<?php
// the args for the WP_Query
// See more @http://codex.wordpress.org/Class_Reference/WP_Query
$args = array(
\'post_type\' => \'matches\',
\'meta_value\' => \'Shen\',
\'order\' => \'DESC\'
);
?>
<?php $the_query = new WP_Query( $args ); ?>
<?php if( $the_query->the_post() ) : ?>
<?php while ( $the_query->have_posts() ); ?>
<?php $tournament = get_post_meta( $post->ID, \'dbt_tournamentname\', true ); ?>
<?php $team_logo_1 = get_post_meta( $post->ID, \'dbt_team1logo\', true ); ?>
<?php $team_logo_2 = get_post_meta( $post->ID, \'dbt_team2logo\', true ); ?>
<div class="matchesh">
<div class="vs"><?php _e(\'vs\',\'mytheme\'); ?></div>
<div class="vdetails"><a href="<?php the_permalink(); ?>"><?php _e(\'view match information\',\'mytheme\'); ?></a></div>
<div class="vevent"><?php echo $tournament; ?></div>
<div class="teamleft"><img src="<?php echo $team_logo_1; ?>" /></div>
<div class="teamright"><img src="<?php echo $team_logo_1; ?>" /></div>
<div class="clearfix"></div>
</div>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center"><?php _e(\'No matches found featuring "Shen".\',\'mytheme\'); ?></h2>
<p class="center"><?php _e(\'Sorry, no team composition featured the selected champion.\',\'mytheme\'); ?></p>
<?php endif; ?>
<?php wp_reset_postdata(); ?>