Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
I think this can be achieved through CSS, may you please post a link to your website depicting this?
Thread Starter
hermig
(@hermig)
This is the website I’m working on: http://puellamagasin.com/ Haven’t succeeded in finding a website with the layout I’m aiming for, but I know I’ve seen it done before. Will keep searching!
Using this code you can show the post in Horizontal sequence :
function post() {
$args = array(
'showposts' => $num,
'numberposts' => 5
);
$results = get_posts($args);
if ($results) {
$counter = 0;
echo '<ul>';
foreach ($results as $result) {
echo '<li class="item">';
echo '<h3><a href="'.get_permalink($result->ID) . '">'.$result->post_title.'</a></h3>';
echo '</li>';
}
echo '</ul>';
}
}
the general approach is to style each post div (.post
in your case) with a ‘float:left;’ and a width of less than 50%;
if the posts can have different heights, you might need to add a ‘clear:both;’, possibly by adding a special css class, to each first post in a row.
btw:
your code seems to be missing a </div>
in the loop.