Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Querying child pages into even columns WordPress

  • SOLVED

Hi,

Building a services page overview and would like to query all child pages of a predefined id, then divided that content alphabetically into 2 columns.

<strong>Currently using this;</strong>

<?php query_posts(array('post_parent' => 7, 'orderby' => 'menu_order', 'order' => 'asc' , 'post_type' => 'page' )); while (have_posts()) { the_post(); ?>

However, I have read you can evenly divided ‘posts’ into columns;

[[LINK href="http://fwd4.me/VWp"]]http://fwd4.me/VWp[[/LINK]]

<em>I design and build WP themes for a living, I just never have to code :)</em>

Answers (1)

2010-07-03

Oleg Butuzov answers:

//template code
<div class="columncontainer">
<?php
$numerator = 1;
while (have_posts()) { the_post(); ?>
<div class='column <?php echo ++$i%2?>'>
<?php /*you post here*/ ?>

<?php the_title(); ?>

</div>
<?php } ?>
<div class="c"></div>
</div>


//css
.columncontainer { width:400px; }
.column { float:left; width:199px;}
.c { clear:both;}

or

//
.columncontainer { width:400px; }
.column0 { float:left; width:199px;}
.column1 { float:right; width:199px;}
c { clear:both;}


West Coast Design Co. comments:

Thanks Oleg,

Although it seems to generate this;

<div class='column1'>
<h6>Service 1</h6>
</div>

<div class='column0'>
<h6>Service 2</h6>
</div>

<div class='column1'>
<h6>Service 3</h6>
</div>

<div class='column0'>
<h6>Service 4</h6>
</div>


I guess I can work with this :) for those who might be interested in the same thing;

<?php

$numerator = 1;

query_posts(array('post_parent' => 9, 'orderby' => 'menu_order', 'order' => 'asc' , 'post_type' => 'page' ));

while (have_posts()) { the_post(); ?>

<div class='column<?php echo ++$i%2?>'>

<?php the_title(); ?>

</div>

<?php } ?>

<div class="c"></div>

</div>


Cheers!