Use CSS and float each of the post blocks left.
Thank you, Esmi,
I’m sorry for probably a stupid question, but how do i designate post id withing the loop? should i use some kind of plugin or there is a function to it?
I have thumbnails to represent posts, and right now the loop looks like this:
[Code moderated as per the Forum Rules. Please use the pastebin]
so i guess i need id for thumbnails, right? to keep the structure
again, i’m sorry, i’m new to all this, but i would really appreciate your help
Why do you need to designate post id within the Loop? It’s not essential. All you need is a post class so that every post is floated left.
basically, it would be easier to visualise if you imagine a table in which each cell is a post, right? and my homepage image will take 4 cells (two upper and two lower) somewhere in the center of this table. and i dont want it to cover my posts, that is why i thought knowing ids of posts would help me to situate them wherever i want them to be altogether with homepage image.
though i understood what you mean and am really thankful 🙂
You could style on the post ids but that would mean having to adjust the CSS every time you published a new post. Or outputting post id specific CSS via the <head></head> section of the page – which would be tricky.
Four posts (with a computed overall width of 50%) floated left will align in two columns of two.
thank you Esmi!
However manual adjustment is somewhat difficult to maintain.
anyway, thank you again for sharing ideas 🙂
ok, guys. been a while and i figured it out recently. maybe just in case someone will need it, the code is:
<ul class="block1">
<?php $posts = get_posts ("numberposts=1"); ?>
<?php if ($posts) : ?>
<?php foreach ($posts as $post) : setup_postdata ($post); ?>
<li><h2><a href="<?php the_permalink(); ?>" <?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?></a></h2></li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
<ul class="block2">
<?php $posts = get_posts ("numberposts=1&offset=1"); ?>
<?php if ($posts) : ?>
<?php foreach ($posts as $post) : setup_postdata ($post); ?>
<li><h2><a href="<?php the_permalink(); ?>" <?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
</a></h2></li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
and so on and so forth.
where: numberposts=1 tells to display (1) post in a block
offset=1 tells to omit previous (1) post
<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
allows you to use thumbnail instead of content and stuff…
css is styled to your preferences
🙂