Advertisement
alchymyth

wp_list_pages ito columns

May 7th, 2011
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php //to auto break list of pages into colunms
  2. $list = wp_list_pages('title_li=&depth=1&echo=0'); //keep 'echo=0' and 'depth=1'; add all your parameters;
  3. $list_elements = explode('</li>', $list);
  4. $num = count($list_elements)-1;
  5. $num_col = 9; //set the max number per column
  6. $col = ceil($num/$num_col);
  7.  
  8. $width = floor(100/$col)-5;
  9. $style = 'width:'.$width.'%;margin-right:2%;padding-left:3%;background: #eee;float:left;';
  10.  
  11. for( $i=1; $i<$col; $i++) { $list_elements[$i*$num_col] = '</ul><ul style="'.$style.'">'.$list_elements[$i*$num_col]; }
  12. $list = implode('</li>', $list_elements); ?>
  13.  
  14. <ul style=" <?php echo $style; ?>">
  15. <?php echo $list; ?>
  16. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement