如何在post中添加添加标记的支持。我什么都试过了,但标签后的选项还是看不见/出现了。

register_post_type( 'articles',
array(
'labels' => array(
'name' => __( 'Articles' ),
'singular_name' => __( 'Articles' )
),
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'excerpt','page-attributes','post-formats','custom-field' ),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'articles'),
)
);发布于 2017-11-20 08:05:43
在这段代码中,您可以获得带有自定义标记的自定义post类型。
试试这段代码,
//* Create Custom Post Type
add_action( 'init', 'add_custom_post_type' );
function add_custom_post_type() {
register_post_type( 'members',
array(
'labels' => array(
'name' => __( 'Members', 'wpsites' ),
'singular_name' => __( 'Member', 'wpsites' ),
),
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-admin-users',
'public' => true,
'rewrite' => array( 'slug' => 'members', 'with_front' => false ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes' ),
'taxonomies' => array( 'member-type' ),
'menu_position' => 2,
));
}
add_action( 'init', 'create_custom_tag' );
function create_custom_tag() {
register_taxonomy(
'tag',
'members',
array(
'label' => __( 'Tag' ),
'rewrite' => array( 'slug' => 'tag' ),
'hierarchical' => true,
)
);
}
它会对你有用的
发布于 2017-11-20 07:52:40
您需要将post_tag分类法添加到寄存器函数中:
register_post_type( 'articles',
array(
'labels' => array(
'name' => __( 'Articles' ),
'singular_name' => __( 'Articles' )
),
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'excerpt','page-attributes','post-formats','custom-field' ),
'taxonomies'=>array('post_tag'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'articles'),
)
);https://stackoverflow.com/questions/47384473
复制相似问题