我有一个问题(当然),我要直截了当地说:我需要列出所有自定义类别,并计算每个类别的帖子。
第1类(xx帖子)
我有一个问题(当然),我要直截了当地说:我需要列出所有自定义类别,并计算每个类别的帖子。
第1类(xx帖子)
经过一点努力,我找到了一个解决方案,写下:
<?php
$cat_args = array(\'orderby\' => \'name\', \'show_count\' => \'1\', \'hierarchical\' => \'0\',\'taxonomy\' => \'here goes the taxonomy\');?>
<ul>
<?php
$cat_args[\'title_li\'] = \'\';
wp_list_categories(apply_filters(\'\', $cat_args));
?>
</ul>
像这样的东西应该可以工作(我已经在自定义模板文件中测试了它)。
<?php $terms = get_terms("name_of_your_custom_taxonomy");
foreach($terms as $term)
{
echo $term->slug; // you can display term name, description ..... Look at codex to see the parameters
$items = get_posts( array(
\'post_type\' => \'name_of_your_custom_post_type)\',
\'numberposts\' => -1,
\'taxonomy\' => \'name_of_your_custom_taxonomy\',
\'term\' => $term->slug
) );
$count = count( $items );
echo $count;
}
?>
我遵循wordpress codex网站上关于通过插件创建管理主题的说明。我激活了插件,但我的样式表没有包含在<head>.. 这是我的代码:add_action( \'admin_init\', \'kd_plugin_admin_init\' ); add_action( \'admin_menu\', \'kd_plugin_admin_menu\' ); function kd_plugin_admin_init() { /* Register