wordpress get_categories example

Based on the example on http://codex.wordpress.org/Function_Reference/get_categories, I try to run get_categories function on wordpress. But the result show nothing. Is it because of the new version wordpress 3.0?

<?php 
$categories=  get_categories('child_of=10'); 
  foreach ($categories as $category) {
    $option = '<option value="/category/archives/'.$category->category_nicename.'">';
    $option .= $category->cat_name;
    $option .= ' ('.$category->category_count.')';
    $option .= '</option>';
echo $option;
}
?>

Need help on this one.

Read More

Thanks.

Related posts

Leave a Reply

2 comments

  1. I am using the same data on my local as the one on http://www.sepakpojok.com. From the parent categories “soccer” I am trying to get its subcategories

    Are you sure that the category ‘soccer’ has the same ID on both servers (local and production)?

    If you’ve manually added the categories on each, rather than copying the DB from one to the other, the ID’s for the same cat could be different.

    In other words, are you sure the ‘soccer’ category ID is 10?