Please rotate device to portrait

Be Well WeHo Series Hopes to Bring Community Together

Published 11 months ago in

Series Features Stanford University’s ‘Healthier Living’ and Boston University’s ‘A Matter of Balance’ Workshops, and More WordPress will *not* take the offset into account when it checks for the number of posts. This creates a problem… internally, WordPress makes a simple check to see if the number of pages outnumbers that query’s posts_per_page property. However, while offset will skip posts in the loop, those skipped posts will still be counted when WordPress decides if there are more pages. Whoops!

This little miscalculation means that WordPress will sometimes assume there is another page even if another page does not exist. For example, if you have 15 posts, an offset of 10, and a posts_per_page limit of 25, WordPress will assume that there is a second page even though the first page will only contain 5 posts (which falls short of our 25 posts_per_page limit). That mysterious second page will return a 404 error.

This last little pagination problem is easily corrected by using the found_posts filter hook, like so…

Recent Articles

  • Contact