0

我正在尝试从循环中排除过滤器(slug)。我研究了排除并在代码中的各个地方尝试过。通常我会打破页面。这是代码,我正在尝试更改以排除 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++;
?>
4

1 回答 1

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++;
于 2013-03-07T12:55:19.780 回答