我已经使用了我的珠宝后类型风箱代码,您只需更换您的后类型&;分类学只需复制(&A);粘贴到函数文件上。
<?php
//Register a Jewelry post type.
function jewelry_post_register() {
$labels = array(
\'name\' => _x( \'Jewelries\', \'post type general name\', \'twentytwelve\' ),
\'singular_name\' => _x( \'Jewelry\', \'post type singular name\', \'twentytwelve\' ),
\'menu_name\' => _x( \'Jewelries\', \'admin menu\', \'twentytwelve\' ),
\'name_admin_bar\' => _x( \'Jewelry\', \'add new on admin bar\', \'twentytwelve\' ),
\'add_new\' => _x( \'Add New\', \'Jewelry\', \'twentytwelve\' ),
\'add_new_item\' => __( \'Add New Jewelry\', \'twentytwelve\' ),
\'new_item\' => __( \'New Jewelry\', \'twentytwelve\' ),
\'edit_item\' => __( \'Edit Jewelry\', \'twentytwelve\' ),
\'view_item\' => __( \'View Jewelry\', \'twentytwelve\' ),
\'all_items\' => __( \'All Jewelries\', \'twentytwelve\' ),
\'search_items\' => __( \'Search Jewelries\', \'twentytwelve\' ),
\'parent_item_colon\' => __( \'Parent Jewelries:\', \'twentytwelve\' ),
\'not_found\' => __( \'No Jewelries found.\', \'twentytwelve\' ),
\'not_found_in_trash\' => __( \'No Jewelries found in Trash.\', \'twentytwelve\' )
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'jewelries\' ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'custom-fields\' )
);
register_post_type( \'jewelry\', $args );
}
add_action( \'init\', \'jewelry_post_register\' );
// create two taxonomies, Categories and writers for the post type "jewelry"
function create_jewelry_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
\'name\' => _x( \'Jewelry Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Jewelry Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Jewelry Categories\' ),
\'all_items\' => __( \'All Jewelry Categories\' ),
\'parent_item\' => __( \'Parent Jewelry Category\' ),
\'parent_item_colon\' => __( \'Parent Jewelry Category:\' ),
\'edit_item\' => __( \'Edit Jewelry Category\' ),
\'update_item\' => __( \'Update Jewelry Category\' ),
\'add_new_item\' => __( \'Add New Jewelry Category\' ),
\'new_item_name\' => __( \'New Jewelry Category Name\' ),
\'menu_name\' => __( \'Jewelry Category\' ),
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'jewelry-category\' ),
);
register_taxonomy( \'jewelry-category\', array( \'jewelry\' ), $args );
}
add_action( \'init\', \'create_jewelry_taxonomies\', 0 );
function my_custom_template_include( $template ) {
if ( get_query_var(\'post_type\') == \'jewelry\' ) {
if ( is_single() ) {
if ( $single = locate_template( array( \'single-jewelry.php\') ) )
return $single;
}
}
return $template;
}
add_filter( \'template_include\', \'my_custom_template_include\' );
add_filter( \'template_include\', \'insert_my_template\' );
function insert_my_template( $template )
{
if ( \'jewelry\' === get_post_type() && !is_single() )
return dirname( __FILE__ ) . \'/archive-jewelry.php\';
return $template;
}
?>
根据你的问题,我的网站运行得很好。