我创建了一个使用自定义帖子的页面:http://www.africanhealthleadership.org/resources/toolkit/
每个工具(准备、评估等)都是一个自定义帖子。在WP Admin上,每个工具都是一个类别;每个类别都有一个“描述”字段。我想在Toolkit页面上输出这些描述。我尝试使用此选项,但未显示任何内容:<?php echo category_description( $category ); ?>
现在,描述已硬编码到页面中。准备工作开始于“准备工具建立……”
谢谢你的建议!杰夫
这是一个循环,用于显示自定义帖子类型:
<?php
query_posts( array( \'post_type\' => \'portfolio\', \'toolkit\' => \'preparation\' ) );
//the loop start here
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<?php the_content(); ?>
<?php endwhile; endif; wp_reset_query(); ?>
下面是函数的代码。php
add_action(\'init\', \'portfolio_register\');
function portfolio_register() {
$labels = array(
\'name\' => _x(\'Toolkit\', \'post type general name\'),
\'singular_name\' => _x(\'Tool\', \'post type singular name\'),
\'add_new\' => _x(\'Add New Tool\', \'tool\'),
\'add_new_item\' => __(\'Add New Tool\'),
\'edit_item\' => __(\'Edit Tool\'),
\'new_item\' => __(\'New Tool\'),
\'view_item\' => __(\'View Tool\'),
\'search_items\' => __(\'Search Toolkit\'),
\'not_found\' => __(\'Nothing found\'),
\'not_found_in_trash\' => __(\'Nothing found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_icon\' => get_stylesheet_directory_uri() . \'/article16.png\',
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\',\'editor\',\'thumbnail\')
);
register_post_type( \'portfolio\' , $args );
}
register_taxonomy("toolkit", array("portfolio"), array("hierarchical" => true, "label" => "Tool Categories", "singular_label" => "Tool", "rewrite" => true));