WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.