Very short snippet: Wordpress, separate the categories into two columns

Inspired by WordPress Hack # 2 - Separate the categories in the sidebar columns can be useful "split" into two columns list the categories of WordPress. e “chiudendo” con l'opportuna width il tag ul , in modo a mandare “a capo” il successivo li . If the sequence that we get is from left to right, ie cat1 | cat2 (head) cat3 | cat4 (head) etc ... no need to use PHP code, but just play with the styles setting the tag li to float:left and "closing" with the appropriate width tag ul , in order to send the "head" on the next li . For cases where the css does not arrive, for example in the sequence cat1 | cat3 (head) cat2 | cat4, we can use this simple code:

1
2
3
4
5
6
explode ( "<br />" , wp_list_categories ( 'title_li=&echo=0&depth=1&style=none' ) ) ; $ Cats = explode ("<br />" wp_list_categories ('title_li = & echo = 0 & depth = 1 & style = none'));
round ( ( sizeof ( $cats ) - 1 ) / 2 ) ; $ Middle = round (( sizeof ($ cats) - 1) / 2);
array_slice ( $cats , 0 , $middle ) ; $ Cats_left = array_slice ($ cats, 0, $ middle);
array_slice ( $cats , $middle , - 1 ) ; $ Cats_right = array_slice ($ cats, $ middle, - 1);
. implode ( '</li><li>' , $cats_left ) . '</li></ul>' . echo '<ul class="left"> <li>'. implode ('</ li>', $ cats_left). '</ li> </ ul>'.
implode ( '</li><li>' , $cats_right ) . '</li></ul>' ; '<ul Class="right"> <li>'. implode ('</ li>', $ cats_right). '</ li> </ ul>';

A comment: "Very short snippet: Wordpress, separate the categories into two columns"

  1. November 19, 2008 AndyEwo232 :

    Thanks for the link, great post

Leave a comment

TAG XHTML PERMITS: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL 


Stop SOPA