split wplist pages in to two columns.
-
Hi all, I’ve put together the following code to split a list of pages in to two columns. It prints ok but as one column. Any idea where the mistake may be?
Thanks
<?php $children = get_pages('child_of='.$post->ID); $parent = $post->post_parent; $siblings = get_pages('child_of='.$parent); if( count($children) != 0) { $args = array( 'depth' => 1, 'title_li' => '', 'child_of' => $post->ID ); } elseif($parent != 0) { $args = array( 'depth' => 1, 'title_li' => '', 'exclude' => $post->ID, 'child_of' => $parent ); } if(count($siblings) > 1 && !is_null($args)) { $list = wp_list_pages($args); $list_elements = explode('</li>', $list); $num = count($list_elements)-1; $col = 2; //set the number of columns $num_col = ceil($num/$col); $width = floor(290/$col)-5; $style = 'width:'.$width.'%;float:left;'; for( $i=1; $i<$col; $i++) { $list_elements[$i*$num_col] = '</ul><ul class="related-practice-areas" style="'.$style.'">'.$list_elements[$i*$num_col]; } $list = implode('</li>', $list_elements); ?> <?php echo $list; } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘split wplist pages in to two columns.’ is closed to new replies.