首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在“自定义管理”菜单下显示自定义分类法?

如何在“自定义管理”菜单下显示自定义分类法?
EN

WordPress Development用户
提问于 2019-02-09 12:31:02
回答 2查看 482关注 0票数 1

我在自定义管理菜单下显示自定义分类法有问题。自定义post类型正确显示,但分类法未出现。

我添加到自定义的post类型:'show_in_menu‘=> 'my-menu'

My自定义菜单

  • Custom Post类型1
  • Custom Post类型2
  • Custom Post类型3
  • 可由Post类型1/2/3使用的Custom分类法

我需要做些什么来显示自定义分类法?

<#>更新

这是我的密码:

代码语言:javascript
复制
function create_custom_admin_menu() {
  add_menu_page(
    'My Menu',
    'My Menu',
    'read',
    'my-menu',
    '',
    'dashicons-admin-page',
    10
  );
}
add_action( 'admin_menu', 'create_custom_admin_menu' );


function create_custom_post_type_1() {
  $labels = array(
    'name' => _x( 'Custom Post 1' ),
    'singular_name' => _x( 'Custom Post 1' ),
    'menu_name' => __( 'Custom Post 1' ),
  );
  register_post_type( 'custom-post-type-1', array(
    'labels' => $labels,
    'has_archive' => false,
    'public' => true,
    'show_in_menu' => 'my-menu',
    'supports' => array( 'title', 'editor', 'auther', 'excerpt', 'custom-fields', 'thumbnail','comments' ),
    'taxonomies' => array( 'custom-taxonomy' ),
    'exclude_from_search' => false,
    'capability_type' => 'post',
    )
  );
}
add_action( 'init', 'create_custom_post_type_1' );


function register_custom_taxonomy() {
  $labels = array(
    'name' => _x( 'Custom Taxonomy'),
    'singular_name' => _x( 'Custom Taxonomy' ),
    'menu_name' => __( 'Custom Taxonomy' ),
  );
  register_taxonomy( 'custom-taxonomy', 'my-menu', array(
    'hierarchical' => true,
    'labels' => $labels,
    'query_var' => true,
    'show_admin_column' => true
  ) );
}
add_action( 'init', 'register_custom_taxonomy' );

<#>UPDATE 2

我试过了,但都没有用:

代码语言:javascript
复制
register_taxonomy( 'custom-taxonomy', 'my-menu', [...]


register_taxonomy( 'custom-taxonomy', 'custom-post-type-1', [...]


register_taxonomy( 'custom-taxonomy', array('custom-post-type-1', 'custom-post-type-2', 'custom-post-type-3' ), [...]
EN

回答 2

WordPress Development用户

发布于 2019-02-09 13:16:44

您还没有正确注册post类型的分类。您可以这样注册您的帖子类型:

代码语言:javascript
复制
register_post_type( 'custom-post-type-1',

这意味着您的post类型名为custom-post-type-1。但是,当您注册分类法时,您将它注册为名为my-menu的post类型“

代码语言:javascript
复制
register_taxonomy( 'custom-taxonomy', 'my-menu',

您需要为post类型注册分类:

代码语言:javascript
复制
register_taxonomy( 'custom-taxonomy', 'custom-post-type-1',
票数 1
EN

WordPress Development用户

发布于 2019-02-09 12:57:56

我认为你的插件有问题。这就是为什么没有出现自定义分类法。

关闭所有插件。那就让他们一次一个。这样,你就能找到有缺陷的那个。您必须删除它并使用另一个选项。

票数 -1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/328194

复制
相关文章

相似问题

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