我试图从循环中排除过滤器(slug)。我研究了排除,并在代码中的各个地方尝试过。通常我打破了页面。这是代码,我试图改变以排除子弹20.这是一个名为'american'的过滤器。我试图在数组的开头排除,没有工作;然后,我尝试了foreach($ catz as $ cat)部分。我试过这个'exclude = 20& title_li ='。我试过cat = -20和其他各种组合。任何帮助都将非常感激。
// The Custom Query
$args = array(
'post_type' => 'portfolio',
'posts_per_page' => $counter_folio,
'paged' => $paged,
'order' => 'DESC'
);
query_posts( $args );
while( have_posts() ) : the_post();
$color = substr(get_option('dcb_dynamic_color'), 1);
// Get the original thumbnail of the post
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), false, '' );
$excerpt = get_the_excerpt();
// Get the custom fields
$vimeo = get_post_meta($post->ID, "vimeo", true);
$youtube = get_post_meta($post->ID, "youtube", true);
// Get the filter > Category of item
$catz = wp_get_object_terms($post->ID,'filters');
foreach($catz as $cat){
$currcat = $cat->slug;
$catname = $cat->name;
break;
}
$counter++;
?>
答案 0 :(得分:0)
如果您要过滤ID为20的帖子,请使用以下代码将其排除
// The Custom Query
$args = array(
'post_type' => 'portfolio',
'posts_per_page' => $counter_folio,
'paged' => $paged,
'order' => 'DESC'
);
query_posts( $args );
while( have_posts() ) : the_post();
$color = substr(get_option('dcb_dynamic_color'), 1);
// Get the original thumbnail of the post
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), false, '' );
$excerpt = get_the_excerpt();
// Get the custom fields
$vimeo = get_post_meta($post->ID, "vimeo", true);
$youtube = get_post_meta($post->ID, "youtube", true);
// Get the filter > Category of item
$catz = wp_get_object_terms($post->ID,'filters');
foreach($catz as $cat){
if($cat->slug != 'american')
{
$currcat = $cat->slug;
$catname = $cat->name;
break;
}
}
$counter++;