wordpress文章列表排除指定自定义字段代码

zhuanbike 2020-5-28 2248

开发中可能会遇到需要将指定自定义字段文章排除,这里直接上代码:

<?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(); ?>


最新回复 (0)
发新帖