我想在“Posts”标签中直接显示一些分类法,作为标准的post,而不是像exp的“Books”这样的单独标签,但我不知道如何显示。有没有办法做到这一点?代码如下:
类PostTypes{
var $types = array();
var $taxonomy = array();
function __construct($types = array(), $taxonomy = array()){
$this->types = $types + $this->types;
$this->taxonomy = $taxonomy + $this->taxonomy;
$this->init();
}
function init(){
add_action( \'init\', array(&$this, \'register_post_type\',) );
add_action( \'init\', array(&$this, \'register_taxonomy\',) );
}
function register_post_type(){
global $options;
foreach ($this->types as $k => $v){
$vowels = array(\'a\', \'e\', \'i\', \'o\', \'u\');
$a = \'a\';
$slug = $v[\'slug\'];
$name = $v[\'name\'];
$plural = $name.\'s\';
$menu_name = $plural;
if(isset($v[\'menu-name\']))
$menu_name = $v[\'menu-name\'];
$labels = array(
\'name\' => __( $plural, \'post type general name\' ),
\'singular_name\' => __( $name, \'post type singular name\' ),
\'add_new\' => __( \'Add New\', strtolower( $name ) ),
\'add_new_item\' => __( \'Add New \' . $name ),
\'edit_item\' => __( \'Edit \' . $name ),
\'new_item\' => __( \'New \' . $name ),
\'all_items\' => __( \'All \' . $plural ),
\'view_item\' => __( \'View \' . $name ),
\'search_items\' => __( \'Search \' . $plural ),
\'not_found\' => __( \'No \' . strtolower( $plural ) . \' found\'),
\'not_found_in_trash\' => __( \'No \' . strtolower( $plural ) . \' found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => $menu_name
);
$supports = array(\'title\',\'editor\',\'thumbnail\', \'comments\');
if(isset($v[\'supports\'])){
$supports = $v[\'supports\'];
}
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => false,
\'rewrite\' => array(\'slug\' => $slug),
\'capability_type\' => \'post\',
\'has_archive\' => false,
\'hierarchical\' => false,
\'menu_position\' => 5,
\'taxonomies\' => array(),
\'supports\' => $supports
);
register_post_type($k, $args);
}
}
function register_taxonomy(){
foreach ($this->taxonomy as $k => $v){
$taxonomy_slug = $v[\'slug\'];
$name = $v[\'name\'];
$plural = $name.\'s\';
$types = $v[\'post-types\'];
$labels = array(
\'name\' => __( $name, \'taxonomy general name\' ),
\'singular_name\' => __( $name, \'taxonomy singular name\' ),
\'search_items\' => __( \'Search \' . $name ),
\'popular_items\' => __( \'Popular \'.$name ),
\'all_items\' => __( \'All \'.$name ),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __( \'Edit \'.$name ),
\'update_item\' => __( \'Update \'.$name ),
\'add_new_item\' => __( \'Add New \'.$name ),
\'new_item_name\' => __( \'New \'.$name.\' Name\' ),
\'separate_items_with_commas\' => __( \'Separate \'.$name.\' with commas\' ),
\'add_or_remove_items\' => __( \'Add or remove \'.$name ),
\'choose_from_most_used\' => __( \'Choose from the most used \'.$name ),
\'menu_name\' => __( $name ),
);
if($v[\'type\'] == \'category\'){
register_taxonomy($k, $types, array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => $taxonomy_slug, \'with_front\' => false),
));
}elseif($v[\'type\'] == \'tags\'){
register_taxonomy($k, $types, array(
\'hierarchical\' => false,
\'labels\' => $labels,
\'show_ui\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => $taxonomy_slug, \'with_front\' => false),
));
}
}
}
}