Advertisement
alchymyth

Untitled

May 9th, 2011
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Columns of Children
  4. */
  5.  
  6. get_header(); ?>
  7.  
  8.         <div id="primary">
  9.             <div id="content" role="main">
  10.  
  11.                 <?php if(wp_list_pages("child_of=".$post->ID."&echo=0")) { ?>
  12.  
  13.                     <?php //to auto break list of pages into colunms
  14.                         $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;
  15.                         $list_elements = explode('', $list);
  16.                         $num = count($list_elements)-1;\
  17.                         $col = 3; //SET THE NUMBER OF COLUMNS
  18.                         $num_col = ceil($num/$col);
  19.  
  20.                         $width = floor(100/$col)-5;
  21.                         $style = 'width:'.$width.'%;margin-right:2%;padding-left:3%;float:left;';
  22.  
  23.                         for( $i=1; $i<$col; $i++) { $list_elements[$i*$num_col] = '<ul style="'.$style.'">'.$list_elements[$i*$num_col]; }
  24.                             $list = implode('', $list_elements); ?>
  25.  
  26.                         <ul class="page-list-columns" style=" <?php echo $style; ?>">
  27.                             <?php echo $list; ?>
  28.  
  29.                         <div style="clear:both;width:100%;display:block;"> </div>
  30.                 <?php } ?>
  31.  
  32.             </div><!-- #content -->
  33.         </div><!-- #primary -->
  34.  
  35. <?php get_sidebar(); ?>
  36. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement