Bug in custom loop
-
Hi, community
I am developing a new theme and I have a bug in the loop. Maybe somebody can see it better than me, after 2h of searching for the bug I am out of order right now.Them main problem is: My loop displays not only posts of the category 111, but also other posts. But not all other posts. and I cannot see any pattern, why and which posts are displayed besides those of cat 111. My code (I simplified it a little and kicked out some of the args, but the problem remains.) goes basically like this:
<?php $args = array( 'post_type' => 'post', 'category' => 111, 'posts_per_page'=> -1, ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); ?> <div class="ratingliste"> <h6> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </h6> </div><!--.ratingliste--> <?php } } wp_reset_postdata(); ?>
But I tried all kind of loops, in the end I just googled them out and replaced parts of the loop with copy and paste. But the bug does not disappear.
Has anybody an idea, why posts of other cats are also shown?
THANKS!
Raphael
- The topic ‘Bug in custom loop’ is closed to new replies.