Limit the number of posts from a specific category on index.php

The problem with this, as it often is, is not just homepage, but the continuous nature of pagination.

Let’s say we start with 10 posts on home page and 5 of them social. Client says that they would like 2 less of social.

We can get rid of them easily enough, but now we need to “borrow” two more posts from second page. So we do that.

But next user clicks to second page. Instead of straightforward “next 10 posts” our logic is now “10 posts, after first 10, but displaying social posts we didn’t display there and not displaying normal posts, which first page took from this one”. Along these lines.

Next user clicks to page three… It compounds.

The only sane solution is two loops indeed. We leave normal posts and pagination up to main loop and we splice in anything extra in between (not necessarily modifying post array even, can just count and do something after every Nth post in loop), or displaying them separately as asides.