Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在自定义贴子类型中显示标记面板_Php_Wordpress_Custom Post Type - Fatal编程技术网

Php 在自定义贴子类型中显示标记面板

Php 在自定义贴子类型中显示标记面板,php,wordpress,custom-post-type,Php,Wordpress,Custom Post Type,我刚做了一个自定义的帖子类型。如何在侧边栏上显示与帖子类型相同的标记面板?将这一行添加到主题文件夹中functions.php中的register\u Post\u type部分 'taxonomies' => array('category', 'post_tag') 完整代码如下所示 add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'posttyp

我刚做了一个自定义的帖子类型。如何在侧边栏上显示与帖子类型相同的标记面板?

将这一行添加到主题文件夹中functions.php中的
register\u Post\u type
部分

'taxonomies' => array('category', 'post_tag') 
完整代码如下所示

add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'posttypename',
        array(
            'labels' => array(
                'name' => __( 'PostTypeName' ),
                'singular_name' => __( 'PostTypeName' )
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'posttypename'),
            'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail' ),
            'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
        )
    );
}

如果您使用
'taxonomies'=>数组('category','post_tag')
,则wordpress default post的标记将显示在自定义post类型区域中

这里是“新闻”帖子类型的干净和独特的方式。不与其他自定义帖子类型、默认标签等混合

您可以查看以下内容的全部详细信息:


希望这会有所帮助。

除了默认的WP codex模板之外,我还需要添加的是

'taxonomies' => array('post_tag'),    

你能给我看一下你在then functions.php中添加的创建自定义帖子类型的代码吗?这就是我想要的:
'taxonomies'=>array('category','post_tag')
。谢谢,钱杜!
'taxonomies' => array('post_tag'),