最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

posts - Remove CategoriesTags From Admin Menu

programmeradmin4浏览0评论

I want to remove or hide Categories / Tags submenu under Posts in the Admin Menu. I know this works with the themes submenus:

remove_submenu_page( 'themes.php', 'widgets.php' );

The same doesn't seem to work for posts unfortunately:

remove_submenu_page( 'edit.php', 'edit-tags.php' );

I'm using the admin_menu action: add_action( 'admin_menu', 'function_call' )

Do I need to add something else?

I want to remove or hide Categories / Tags submenu under Posts in the Admin Menu. I know this works with the themes submenus:

remove_submenu_page( 'themes.php', 'widgets.php' );

The same doesn't seem to work for posts unfortunately:

remove_submenu_page( 'edit.php', 'edit-tags.php' );

I'm using the admin_menu action: add_action( 'admin_menu', 'function_call' )

Do I need to add something else?

Share Improve this question edited Mar 11, 2016 at 22:58 Howdy_McGee asked Aug 19, 2013 at 21:54 Howdy_McGeeHowdy_McGee 20.9k24 gold badges91 silver badges177 bronze badges 1
  • 2 Upvote this question, you heathens!!! – Spencer Williams Commented Mar 11, 2016 at 22:55
Add a comment  | 

5 Answers 5

Reset to default 17
add_action('admin_menu', 'my_remove_sub_menus');

function my_remove_sub_menus() {
    remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=category');
    remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag');
}

If you want to completely remove categories and tags you can do so like this:

// Remove Categories and Tags
add_action('init', 'myprefix_remove_tax');
function myprefix_remove_tax() {
    register_taxonomy('category', array());
    register_taxonomy('post_tag', array());
}

You may also want to remove the meta boxes from the Post Creation page

// REMOVE POST META BOXES
function remove_my_post_metaboxes() {
  remove_meta_box( 'categorydiv','post','normal' ); // Categories Metabox
  remove_meta_box( 'tagsdiv-post_tag','post','normal' ); // Tags Metabox
}
add_action('admin_menu','remove_my_post_metaboxes');

Thanks to @mbacon40 and to @gmazzap I was able to use this to remove Product Tags and Categories (product_tag and product_cat) from my menu and from the product add/edit pages.

// Remove Categories and Tags
add_action('init', 'myprefix_remove_tax');
function myprefix_remove_tax() {
    register_taxonomy('product_cat', array());
    register_taxonomy('product_tag', array());
}

add_action('admin_menu', 'my_remove_sub_menus');
function my_remove_sub_menus() {
    remove_submenu_page('edit.php', 'edit-tags.php?    taxonomy=product_cat&post_type=product');
    remove_submenu_page('edit.php', 'edit-tags.php?    taxonomy=product_tag&post_type=product');
}

for some reason the edit.php does not work at my setup 5.3

This however works

remove_submenu_page( 'edit-tags.php?taxonomy=category', 'edit-tags.php?taxonomy=post_tag' );
remove_submenu_page( 'edit-tags.php?taxonomy=category', 'edit-tags.php?taxonomy=category' );
发布评论

评论列表(0)

  1. 暂无评论