WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] 3 Post Columns with query_posts

[Resolved] 3 Post Columns with query_posts

  • I have set my home page up to display posts in three columns using the following:
    http://wordpress.pastebin.com/ES2jdRQY
    Yet when I use the same code on a custom page template, it creates three columns, but after placing posts in the first two, it then resorts to posting the remaining posts in the third. It does not complete a column and then kick to the next. I have no clue why it is doing this.
    Here is the code for my “portfolio.php” custom page template:
    http://wordpress.pastebin.com/tTD8tbNU

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    @keesiemeijer

    in the home page you have $count = 1; and on the portfolio.php you have $count = 3;. I would put $num_of_posts = $wp_query->post_count;
    after the query (on both template files) for an accurate post count:

    <?php $count = 1;
    $col_count = 3;
    $num_of_posts = $wp_query->post_count;
    $post_per_column = ceil($num_of_posts / $col_count); ?>
    <div id="col1">
    <?php query_posts($query_string . '&cat=-121,-123,-124,-125,-126'); ?>

    like so:

    <div id="col1">
    <?php query_posts($query_string . '&cat=-121,-123,-124,-125,-126'); ?>
    <?php $count = 1;
    $col_count = 3;
    $num_of_posts = $wp_query->post_count;
    $post_per_column = ceil($num_of_posts / $col_count); ?>

    Wow, that seems to have worked great! Now if only I can get pagination working properly 😉
    Thanks a ton!

    Got pagination working properly! Thanks for the help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] 3 Post Columns with query_posts’ is closed to new replies.
Skip to toolbar