Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted


foreach(get_categories('parent=0&orderby=id') as $cat) { 
   echo $cat->term_id.' '.$cat->name.'<br/>'; 
share|improve this answer
Perfect Thanks! – Jordash Aug 13 '11 at 4:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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