I have created a Member Directory page and I am attempting to display a list of members under their category name, alphabetically in two columns (div.members-colA and div.members-colB). The members should populate div.members-colA until the rounded post count reaches 1/2, at which time the posts should populate div.members-colB. My code isn't displaying the content this way and I am stumped. Obviously a PHP newbie so any help would be greatly appreciated!! You can view the page on the development server here. http://www.airwaysdigital.com/sauganash/member-directory-2/
CSS:
.members-colA{
width:49%;
float:left;
}
.members-colB{
width:49%;
float:right;
}
.members-colC{
width:100%;
}
PHP:
<div class="members-colA">
<?php
//get all categories then display all posts in each term
$taxonomy = 'category';
$param_type = 'category__in';
$term_args = array(
'orderby' => 'name',
'order' => 'ASC'
);
$terms = get_terms($taxonomy, $term_args);
if ($terms) {
foreach( $terms as $term ) {
$args=array(
"$param_type" => array($term->term_id),
'post_type' => 'members',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1,
'orderby' => 'title',
'order' => 'ASC'
);
$my_query = null;
$my_query = new WP_Query($args);
$i = 0;
if( $my_query->have_posts() ) {
if ($i == 0) ?>
<h3 class="member-category"><?php echo $term->name; ?></h3>
<?php
while ($my_query->have_posts()) : $my_query->the_post();
echo '<div class="members-colC">'; ?>
<p class="member-cat bold"><?php the_title(); ?></p>
<?php the_content();
echo '</div>';
if ($i == round($my_query->post_count / 2)) echo '</div><div class="members-colB">';
if ($i == round($my_query->post_count)) echo '</div>';
$i++;
endwhile;
}
}
} ?>
<?php wp_reset_postdata(); ?>
</div><!-- end .members-colB -->