Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: Columns of Children
- */
- get_header(); ?>
- <div id="primary">
- <div id="content" role="main">
- <?php if(wp_list_pages("child_of=".$post->ID."&echo=0")) { ?>
- <?php //to auto break list of pages into colunms
- $list = wp_list_pages('title_li=&depth=1&echo=0&child_of='.$post->ID.'&sort_column=menu_order');//keep 'echo=0' and 'depth=1'; add all your parameters;
- $list_elements = explode('', $list);
- $num = count($list_elements)-1;\
- $col = 3; //SET THE NUMBER OF COLUMNS
- $num_col = ceil($num/$col);
- $width = floor(100/$col)-5;
- $style = 'width:'.$width.'%;margin-right:2%;padding-left:3%;float:left;';
- for( $i=1; $i<$col; $i++) { $list_elements[$i*$num_col] = '<ul style="'.$style.'">'.$list_elements[$i*$num_col]; }
- $list = implode('', $list_elements); ?>
- <ul class="page-list-columns" style=" <?php echo $style; ?>">
- <?php echo $list; ?>
- <div style="clear:both;width:100%;display:block;"> </div>
- <?php } ?>
- </div><!-- #content -->
- </div><!-- #primary -->
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement