I'm looking to print out All of the Main Categories (So Exclude Sub-Categories) in a Loop, I need to get the ID's to do some advanced category listings.

So I need to echo this out:

3 CatName
4 CatName
5 CatName
x CatName

Where the number is the category # and the CatName is the name of the category




foreach(get_categories('parent=0&orderby=id') as $cat) { 
   echo $cat->term_id.' '.$cat->name.'<br/>'; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.