WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] 3 Post Columns with query_posts (4 posts)

  1. AJ Troxell
    Member
    Posted 3 years ago #

    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

  2. keesiemeijer
    moderator
    Posted 3 years ago #

    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); ?>
  3. AJ Troxell
    Member
    Posted 3 years ago #

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

  4. AJ Troxell
    Member
    Posted 3 years ago #

    Got pagination working properly! Thanks for the help!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.