Title: Skipping posts in the loop
Last modified: August 18, 2016

---

# Skipping posts in the loop

 *  [onocentaur](https://wordpress.org/support/users/onocentaur/)
 * (@onocentaur)
 * [18 years, 7 months ago](https://wordpress.org/support/topic/skipping-posts-in-the-loop/)
 * Actually this is quite complicated and I can’t think how to describe it briefly.
   
   I discovered that urls like ?cat=1,2,3 will return all posts in categories 1,2
   and 3. So I made a search page that allows users to search like this, in a number
   of specified categories. Then I added a piece of code in the loop that skips 
   a post (using continue;) if it’s not in all of the selected categories (default
   is to show all posts in _any_ of the selected categories). Great, it works, but,
   here’s the problem: Although I’m only displaying the right posts, the number 
   of posts visible on one page is a bit random. When my piece of code skips an 
   offending post, the loop continues unawares, and when it gets to the max posts
   in one pages, it stops and you get the ‘more posts’ link, even if the number 
   of posts actually displayed is less than it should be, even 0! Is there any way
   I can make the loop ‘lose’ an offending post? Or change some variables, or something,
   anything, to fix this problem?
 * I’m not sure this is entirely clear but I would be very grateful for any help!
   Thanks!

The topic ‘Skipping posts in the loop’ is closed to new replies.

## Tags

 * [php code](https://wordpress.org/support/topic-tag/php-code/)
 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)

 * 0 replies
 * 1 participant
 * Last reply from: [onocentaur](https://wordpress.org/support/users/onocentaur/)
 * Last activity: [18 years, 7 months ago](https://wordpress.org/support/topic/skipping-posts-in-the-loop/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
