Hi,
I need to also get each category id from wp_list_categories function. Is it possible?
Hi,
I need to also get each category id from wp_list_categories function. Is it possible?
the id is part of the markup:
http://codex.wordpress.org/Template_Tags/wp_list_categories#Markup_and_Styling_of_Category_Lists
but obviously not directly accessible;
if you explain why and what you need the id for, someone might be able to suggest more details.
or use get_categories() instead
http://codex.wordpress.org/Function_Reference/get_categories
As alchymyth said, use get_categories()
<?php
$args=array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
//now you have all categories inside an array and can use foreach loop to go through all category information.
foreach($categories as $category){
// do suff with category id $category->cat_ID
}
?>You must log in to post.