0

I have a theme that creates two columns of categories with child posts from that category. I've tried messing with the code that inserts the after two posts are listed, but it's not working (because I don't know what I'm doing). The current php renders as follows:

<div class="row">
<div class="column col-half">...</div>
<div class="column col-half">...</div>
</div>

I'd like it to render as:

<div class="row">
<div class="column col-third">...</div>
<div class="column col-third">...</div>
<div class="column col-third">...</div>
</div>

Here is the theme's code that renders the HTML:

$st_categories = get_categories($st_hp_cat_args); 
$st_categories = wp_list_filter($st_categories,array('parent'=>0));
if ($st_categories) {
foreach($st_categories as $st_category) { 
$st_cat_counter++;

if ((!is_int($st_cat_counter / 2)) && $st_cat_counter != 1) { 
echo '</div><div class="row">';} elseif ($st_cat_counter == 1) 
{ echo '<div class="row">';}
echo '<div class="column col-half '. $st_cat_counter.'">';
echo '<h3> <a href="' . get_category_link( $st_category->term_id ) . '" title="' .     sprintf( __( 'View all posts in %s', 'framework' ), $st_category->name ) . '" ' . '>' .     $st_category->name.'</a>';
if (of_get_option('st_hp_cat_counts') == '1') {
echo '<span class="cat-count">(' . $st_category->count.')</span>';  
}
echo '</h3>';

Thanks in advance.

1

The code that makes this a two-column layout is centered on the $st_cat_counter variable. This is incremented with each iteration and when it's an even number ($st_cat_counter / 2) a row is closed and a new row is started:

echo '</div><div class="row">';} elseif ($st_cat_counter == 1) 

You should simply be able to change "/ 2" to "/ 3". This changes the break point from every 2nd item to every third item. CSS changes and other edits will be likely to finish the job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.