Wordpress 自定义帖子类别正在相互合并

Wordpress 自定义帖子类别正在相互合并,wordpress,Wordpress,我已经在我的网站上创建了2个自定义帖子,现在的问题是,每当我在第一个自定义帖子中创建任何类别时,它会自动添加到第二个自定义帖子中,我希望每个自定义帖子都有单独的类别 也许我在创建自定义帖子时做错了什么 请帮忙 下面是代码 function create_posttype() { register_post_type( 'case_study', array( 'labels' => array( 'name'

我已经在我的网站上创建了2个自定义帖子,现在的问题是,每当我在第一个自定义帖子中创建任何类别时,它会自动添加到第二个自定义帖子中,我希望每个自定义帖子都有单独的类别

也许我在创建自定义帖子时做错了什么

请帮忙

下面是代码

function create_posttype()
{
    register_post_type( 'case_study',

        array(
            'labels' => array(
                'name' => __( 'Case Study' ),
                'singular_name' => __( 'Case Study' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'case_study'),
            'taxonomies' => array('category'),
            'supports' => array( 'title','thumbnail', 'revisions', 'custom-fields','editor', 'post-templates', 'related-post', 'thumbnail','excerpt'),
        )
    );

    register_post_type( 'healthcare',

        array(
            'labels' => array(
                'name' => __( 'Health care' ),
                'singular_name' => __( 'Health care' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'healthcare'),
            'taxonomies' => array('category'),
            'supports' => array( 'title','thumbnail', 'revisions', 'custom-fields','editor', 'post-templates', 'related-post', 'thumbnail','excerpt'),
        )
    );
}

// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );

function add_case_meta_boxes() {
    add_meta_box("case_contact_meta", "case_study", "add_contact_details_team_meta_box", "case_study", "normal", "low");
}
function add_contact_details_team_meta_box()
{
    global $post;
    $custom = get_post_custom( $post->ID );
?>
    <p>
        <label>Designation: </label><br />
        <input type="text" name="designation" value="<?= @$custom["designation"][0] ?>" class="width99" />
    </p>
    <p>

    <?php
}

function save_case_custom_fields(){
  global $post;

  if ( $post )
  {
    update_post_meta($post->ID, "designation", @$_POST["designation"]);
  }
}
add_action( 'admin_init', 'add_case_meta_boxes' );
add_action( 'save_post', 'save_case_custom_fields' );

/****************/

function add_healthcare_meta_boxes() {
    add_meta_box("healthcare_contact_meta", "healthcare", "add_healthcare_meta_box", "healthcare", "normal", "low");
}
function add_healthcare_meta_box()
{
    global $post;
    $custom = get_post_custom( $post->ID );
?>
    <p>
        <label>Designation: </label><br />
        <input type="text" name="designation" value="<?= @$custom["designation"][0] ?>" class="width99" />
    </p>
    <p>

    <?php
}

function save_healthcare_custom_fields(){
  global $post;

  if ( $post )
  {
    update_post_meta($post->ID, "designation", @$_POST["designation"]);
  }
}
add_action( 'admin_init', 'add_healthcare_meta_boxes' );
add_action( 'save_post', 'save_healthcare_custom_fields' );
函数create_posttype()
{
注册后类型(“案例研究”,
排列(
“标签”=>数组(
“名称”=>“(“案例研究”),
“单数名称”=>(“案例研究”)
),
“public”=>正确,
“has_archive”=>true,
“重写”=>数组(“slug”=>“案例研究”),
“分类法”=>array('category'),
'支持'=>数组('title','thumbnail','revisions','customfields','editor','post templates','related post','thumbnail','extract'),
)
);
注册后类型('healthcare',
排列(
“标签”=>数组(
“名称”=>“‘医疗’”,
“单数名称”=>(“医疗保健”)
),
“public”=>正确,
“has_archive”=>true,
“重写”=>array('slug'=>healthcare'),
“分类法”=>array('category'),
'支持'=>数组('title','thumbnail','revisions','customfields','editor','post templates','related post','thumbnail','extract'),
)
);
}
//将我们的功能连接到主题设置
添加_操作('init','create_posttype');
函数add_case_meta_box(){
添加元框(“案例联系人元”、“案例研究”、“添加联系人详细信息”、“团队元框”、“案例研究”、“正常”、“低”);
}
功能添加\联系人\详细信息\团队\元\框()
{
全球$员额;
$custom=get\u post\u custom($post->ID);
?>

名称:

为什么要将其包装在函数create_posttype()中?是否使用了functions.php中的代码?@charankumar yes删除create_posttype函数并try@charankumar还是一样的问题。:(你可以在这里看到你的答案: