开发者

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.

Thanks.


I am using the same data on my local as the one on 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?


you might want to change it to this:

$categories = get_categories(array('hide_empty' => false, 'child_of' => 10));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜