I have an Easy Digital Downloads archive page the shows published downloads, but also pending downloads although its not suppose to.
for some reason, the wp_count_posts() doesn’t affect on the loop, and I can see also pending posts in the archive page. I cant figure out why.

         <?php
            $count_posts = wp_count_posts('download');
            $published_posts = $count_posts->publish;
            $key = 0;
            ?>
            <?php if (have_posts()) : ?>
                <div class="all_product">
                    <div class="row">
                        <?php while (have_posts()) : the_post();
                            if ($key < 12) {
                                ?>

                                <div class="col-lg-3 col-md-4 col-sm-12 single-download-list">
                                    <?php get_template_part('content-grid', 'download'); ?>
                                </div>

                                <?php
                            }
                            $key++;
                        endwhile; ?>


                    </div>
                </div>
            <?php else : ?>

Read more here: wordpress loop show pending posts even though $count_posts->publish;


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: