个性化阅读
专注于IT技术分析

我想在WordPress中排除某些帖子?

大家好, 我遇到了一个问题, 在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>';
                 }

                 ?>

#1


这似乎对我来说很棒:’exclude’=> array(10)

赞(0)
未经允许不得转载:srcmini » 我想在WordPress中排除某些帖子?

评论 抢沙发

评论前必须登录!