Posts Tagged ‘The Loop’
WordPress: get posts within the loop
Posted by Dimitri | Filed under Programming
This post will explain how to get posts at the WordPress loop, so you can place code (probably advertisement code) after a specific post (first, second, third) or at intervals (e.g.: every 3 posts).
Before starting, it is a good idea to create a backup copy of your theme’s index.php file, just in case anything goes wrong.
This is a five page post, so here is the page index:
- Get the first post
- Get the 2nd, 3rd or any other post
- Get odd/even posts
- Get post intervals
- Final considerations
Let’s begin by finding where to place the code. That’s why we need to find the WordPress Loop in the index.php file.