Advertisement
alchymyth

page list columns

May 9th, 2011
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 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&child_of='.$post->ID.'&sort_column=menu_order&show_date=modified&date_format=$date_format');?>
  3. '); //keep 'echo=0' and 'depth=1'; add all your parameters;
  4. $list_elements = explode('</li>', $list);
  5. $num = count($list_elements)-1;
  6. $num_col = 5; //CHANGE HERE FOR THE NUMBER OF ITEMS PER COLUMN
  7. $col = ceil($num/$num_col);
  8.  
  9. $width = floor(100/$col)-5;
  10. $style = 'width:'.$width.'%;margin-right:2%;padding-left:3%;float:left;';
  11.  
  12. for( $i=1; $i<$col; $i++) { $list_elements[$i*$num_col] = '</ul><ul style="'.$style.'">'.$list_elements[$i*$num_col]; }
  13. $list = implode('</li>', $list_elements); ?>
  14.  
  15. <ul class="page-list-columns" style=" <?php echo $style; ?>">
  16. <?php echo $list; ?>
  17. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement