您的查询似乎很好,应该可以运行。它不会返回结果,可能是因为您丢失了type
的参数ads_status
领域
所以你的代码应该是。
<?php
$args = array(
\'post_type\' => \'banner\',
\'posts_per_page\' => 25,
\'meta_query\' => array(
\'relation\' => \'AND\',
array(
\'key\' => \'ads_status\',
\'value\' => \'1\',
\'type\' => \'NUMERIC\',
),
array(
\'key\' => \'adsposition\',
\'value\' => \'top\',
),
),
);
$slide = new WP_Query( $args );
if ( $slide->have_posts() ) : while ( $slide->have_posts() ) : $slide->the_post();
$yourfile = get_post_meta(get_the_ID(), \'yourfile\', true);
$adsposition = get_post_meta( get_the_ID(),\'adsposition\', true ); ?>
<img src="<?php echo $yourfile; ?>" width="1350" height="515">
<?php
endwhile; endif;
wp_reset_query();
?>