I found a code to list my categories in 2 columns but now I want it to show the alphabetical headings for example http://www.zomganime.com/anime-series-list/. So does anyone know how? don't say use a plugin because I'm trying to use less plugins to save performance. <?php $cats = explode("<br />",wp_list_categories('title_li=&echo=0&depth=1&style=none')); $cat_n = count($cats) - 1; for ($i=0;$i<$cat_n;$i++): if ($i<$cat_n/2): $cat_left = $cat_left.'<li>'.$cats[$i].’</li>’; elseif ($i>=$cat_n/2): $cat_right = $cat_right.’<li>’.$cats[$i].’</li>’; endif; endfor; ?> <ul class=â€leftâ€> <?php echo $cat_left;?> </ul> <ul class=â€rightâ€> <?php echo $cat_right;?> </ul> Code (markup):
The orderby is not what I'm looking for. It needs to show the alphabetical heading, did you have a look at the example? I want the categories to display like this A apple air acting artist B blue blueberry batman boy
Sorry, I missed your example. You'll have to use a plugin for that (even though you don't want to). AZIndex is one that will give output like you want.
Geekly Weekly has a page order and a link order and a category order plugin that works with WP 2.8. You may have to make slight modifications to your Template.. but it's not that hard.
<?php $cats = explode("<br/>", wp_list_categories('title_li=&echo=0&depth=1&style=none')); $cat_n = count($cats) - 1; for ($i=0; $i<$cat_n; $i++) { $this_letter = strtoupper(substr(trim(strip_tags($cats[$i])), 0, 1)); $this_letter = ctype_alpha($this_letter) ? $this_letter : "#"; // Replace '#' with your desired nonalphabetic heading if ($i<$cat_n/2) { $cat_left .= ($this_letter != $last_letter) ? "<li>{$this_letter}</li>" : ""; $cat_left .= "<li>{$cats[$i]}</li>"; } else { $cat_right .= ($this_letter != $last_letter) ? "<li>{$this_letter}</li>" : ""; $cat_right .= "<li>{$cats[$i]}</li>"; } $last_letter = $this_letter; } ?> PHP: Try this out, contact me via IM if you get any problems
Why bothering? There is already written plugin for this: http://www.dagondesign.com/articles/multi-column-category-list-plugin-for-wordpress/
Did you not read my first post I said I don't want to use a plugin cause I want to save performance on my site, anyway I got the code working