• Hi,

    I’m trying to set up a magazine theme and I want the posts on the index page to be set up like this (with the numbers representing the chronological order):
    1 2
    3 4
    5 6

    How is this possible?

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Horizontally align posts’ is closed to new replies.