我想在输入中列出我所有Wordpress帖子的类别:
<input type="checkbox" class="something" id="[category-name]" value="[category-name] + ([amount of posts that have this category])" />
任何可以帮助我的人,提前谢谢!
答案 0 :(得分:1)
您可能希望考虑格式化get_categories()
的输出:
$catlist = get_categories();
foreach ($cat in $catlist) {
$tag = '<input type="checkbox" class="something" id="';
$tag .= $cat->name;
$tag .= '" value="';
$tag .= $cat->name;
$tag .= ' + (';
$tag .= $cat->count;
$tag .= ')" />';
echo $tag;
}
来自WP Codex:http://codex.wordpress.org/Function_Reference/get_categories#Return_values