首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在自定义菜单中添加支持标记的wordpress仪表板

在自定义菜单中添加支持标记的wordpress仪表板
EN

Stack Overflow用户
提问于 2017-11-20 02:59:35
回答 2查看 23关注 0票数 0

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

代码语言:javascript
复制
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'),
    )
);
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-11-20 08:05:43

在这段代码中,您可以获得带有自定义标记的自定义post类型。

试试这段代码,

代码语言:javascript
复制
//* 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,
		)
	);
}

它会对你有用的

票数 1
EN

Stack Overflow用户

发布于 2017-11-20 07:52:40

您需要将post_tag分类法添加到寄存器函数中:

代码语言:javascript
复制
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'),
    )
);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47384473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档