Reputation: 43
I am currently working on blog page for a custom Wordpress theme. This page consists of all the posts available in thumbnail format. You click a thumbnail, you go to that post. I know how to do a basic post loop so every thumbnail shows. I also know how to add HTML within that loop. However I need to know how to add a div ONLY after the first post is placed. The first post that's placed should be the latest post, thus the largest. Next to that I need another div that has nothing to do with the posts.
How do I make a loop that places a div ONLY after the first post. Then continues placing the other post thumbnails. See the image below.
Upvotes: 0
Views: 1024
Reputation: 1432
2 Options:
1) Use 2 loops, one that just gets one post on top and the second that excludes that post but gets the rest.
2) Use and iterator or post_count and check:
if(i === 0){
//Bigger div with unrelated dive here
}else{
//Normal grid layout html
}
Upvotes: 0
Reputation: 699
you can use a basic if constuct. Before a loop starts set variable
$someVariable = 0;
then in the loop, after the post is displayed:
if ($someVariable == 0) {
print "<div>whatever</div>"
$someVariable++;
}
Upvotes: 1