开发中可能会遇到需要将指定自定义字段文章排除,这里直接上代码:
<?php query_posts( array(
'post_type' => 'post',
'ignore_sticky_posts'=> 1,
'meta_query' => array(
array(
'key' => 'cat-top', //循环内容
'compare' => 'NOT EXISTS'
)),
'showposts' => 8,
'orderby' => 'rand'
));
if (have_posts()) :while (have_posts()) : the_post();?>
<?php endwhile;endif;wp_reset_query(); ?>