i have a lot of categories and subcategories in my site. I display them manually, i mean i wrote:
<ul>
<li>..menu..</li>
<li>..menu..</li>
</ul>
I'm sure there is a right way to do it. I'm sure there is an function for that. Can anybody tell me ?
Thanks
Sure, you can use wp_list_categories()
Yes, there is.
Use wp_list_categories()
:
An example:
<ul>
<?php wp_list_categories('orderby=name&show_count=1&exclude=10'); ?>
</ul>
This function takes care of the formatting too. If you want the unformatted results, you can use get_categories()
instead..
In most php-based content management systems, this will be handled by getting the object containing the categories and a foreach() loop.
echo "<ul>";
foreach($menus as $menu) {
echo "<li>" . $menu->link . "</li>";
}
echo "</ul>";
Every CMS will have its own objects, but the loop is pretty standard.