Reputation: 2549
I'm getting stuck on a quite simple problem (I guess). I am trying to get categories within my template order the same way they are ordered in my main menu.
For information I'm using WP 3.0.4, french version.
Thanks a lot !
Upvotes: 3
Views: 2715
Reputation: 7701
This is not an orthodox method, but we don't have a category sorting field so...
If you are not using the Description field of the categories, you could use this field as a sorting field. Say, introducing a single char from A to Z in admin, and use get_categories() or wp_list_categories() with the option 'orderby' => 'description'
, 'order' => 'ASC'/'DESC'
.
Or, if you do use this field, perhaps some creativity with first words would do it! Like "A category for java articles" instead of "Java articles"; "Bunch of PHP articles" instead of "PHP articles", etc.
Upvotes: 4
Reputation: 2207
Try to use the wp_list_categories() function http://codex.wordpress.org/Template_Tags/wp_list_categories
Use, the orderby parameter. To sort by name, use
<ul>
<?php wp_list_categories('orderby=name'); ?>
</ul>
Upvotes: 0