使用分类法创建自定义帖子类型

时间:2014-01-27 06:36:17

标签: wordpress custom-post-type

我正在尝试使用分类法创建自定义帖子类型。当我激活我的插件时,我会在仪表板上看到所有类别的帖子。但我只显示分类法类别而不是类别。

function propertyinfo_setup_post_types() {

    $PROPERTY_labels =  apply_filters( 'propertyinfo_labels', array(
        'name'                => 'Property Info',
        'singular_name'       => 'Property Info',
        'add_new'             => __('Add New', 'propertyinfo'),
        'add_new_item'        => __('Add New Property', 'propertyinfo'),
        'edit_item'           => __('Edit Property Info', 'propertyinfo'),
        'edit_item'           => __('Edit Property Info', 'propertyinfo'),
        'new_item'            => __('New Property Info', 'propertyinfo'),
        'all_items'           => __('All Property', 'propertyinfo'),
        'view_item'           => __('View Property', 'propertyinfo'),
        'search_items'        => __('Search Propertys', 'propertyinfo'),
        'not_found'           => __('No Propertys found', 'propertyinfo'),
        'not_found_in_trash'  => __('No Propertys found in Trash', 'propertyinfo'),
        'parent_item_colon'   => '',
        'menu_name'           => __('Property Info', 'propertyinfo'),
        'exclude_from_search' => true
    ) );


    $PROPERTY_args = array(
        'labels'            => $PROPERTY_labels,
        'public'            => true,
        'taxonomies' => array('category',),
        'publicly_queryable'=> true,
        'show_ui'           => true,
        'show_in_menu'      => true,
        'query_var'         => true,
        'capability_type'   => 'post',
        'has_archive'       => true,
        'hierarchical'      => true,
        'supports'          => apply_filters('propertyinfo_supports', array( 'title', 'editor','thumbnail','author') ),
    );
    register_post_type( 'propertyinfo', apply_filters( 'propertyinfo_post_type_args', $PROPERTY_args ) );

}

add_action('init', 'propertyinfo_setup_post_types');

1 个答案:

答案 0 :(得分:1)

注册分类法不同。

添加此代码并从属性args中删除taxonomies' => array('category')

register_taxonomy("main_title", array("Property Info"), array("hierarchical" => true, "label" => "cat_lable", "singular_label" => "singular_label", "rewrite" => true));
相关问题