嘿大家我遇到一个问题,在wordpress我使用post__not_in不显示id 10的类别。我试过这个,它似乎仍然拉着帖子。你有解决方案让这项工作。感谢大家!
<?php
$cat_args = array(
'orderby' => 'post_date',
'order' => 'DESC',
'child_of' => 0,
'post__not_in' => array(10),
);
$categories = get_categories($cat_args);
foreach($categories as $category) {
echo '<dl>';
echo '<h3 class="category-name">' . $category->name.'</h3>';
$post_args = array(
'numberposts' => -1,
'category' => $category->term_id
);
$posts = get_posts($post_args);
foreach($posts as $post) {
?>
<dd><a class="article" target="_blank" href="<?php the_field('article_link') ?>"><?php the_title(); ?></a><span class="news-source"> - <?php the_field('news_source') ?></span><p class="important"><?php the_field('important') ?></p></dd>
<?php
}
//echo '<dd class="view-all"> <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>View all posts in ' . $category->name.'</a></dd>';
echo '</dl>';
}
?>
这对我来说似乎很有用:'exclude' => array(10)