blogger_a
Member
Posted 1 year ago #
Hi.
I am making a theme for my wordpress. The basic layot is this:
if (have_posts())
{
the_post();
//print the post
if (have_posts())
{
while (have_posts())
{
the_post();
//print post
if (have_posts())
{
the_post(); // print post
}
}
}
Thats basically all. what it should do is show the latest post in the top center. and then show other posts 2 per row.
The problem is that I have 4 posts for example it shows 1 on the center, 2 posts on a row, and 1 on another row. BUT then it starts showing the latest post once again. So it repeat them once.
Is it some kind of problem with the loops I made?
Thanks
http://codex.wordpress.org/The_Loop
What you want is toward the bottom. You may also want to set up a cat called "Featured" and tell WP to pull the latest post from that category. HTH
blogger_a
Member
Posted 1 year ago #
hi
thanks for your replay.
I'm only reading the all posts not any category specific. This is the main (index) page.
btw everything shows fine when the amount of posts is 3. That is completing the whole row. (1 post in the center) and 2 posts on 1 row...
Try something like this:
<?php
$numposts = 0;
$odd = true;
if (have_posts()){
while (have_posts()){
the_post();
$numposts++;
if (1==$numposts){
// display the first post
}else{
// display the rest of the posts
// check $odd to know whether this is going
// in the left or right of your two-posts-per-row.
// after displaying, toggle value of $odd:
$odd = ($odd) ? false : true;
}
}
}
?>
blogger_a
Member
Posted 1 year ago #