How to add taxonomy to Users menu in admin?

admin2025-01-07  4

I want to create a taxonomy that is related to the users, therefore I'd like to show the taxonomy under "Users" menu within wordpress admin. In codex there's a mention that you can attach taxonomy to "nav_menu_item" but I can't find any working example of how this works. If I use:

register_taxonomy( 'expertise', array( 'nav_menu_item' ), $args );

or

register_taxonomy( 'expertise', array( 'users' ), $args );

it doesn't work.

Any help would be much appreciated.

I want to create a taxonomy that is related to the users, therefore I'd like to show the taxonomy under "Users" menu within wordpress admin. In codex there's a mention that you can attach taxonomy to "nav_menu_item" but I can't find any working example of how this works. If I use:

register_taxonomy( 'expertise', array( 'nav_menu_item' ), $args );

or

register_taxonomy( 'expertise', array( 'users' ), $args );

it doesn't work.

Any help would be much appreciated.

Share Improve this question asked Nov 29, 2014 at 12:34 wyktorwyktor 415 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

The register_taxonomy function is designed only for adding taxonomies to existing post types and custom post types. It's not something that can be expanded to users.

I have just tried a couple of plugins that work with taxonomies and neither are able to attach a taxonomy to a user.

from http://codex.wordpress.org/Function_Reference/register_taxonomy :

Usage

<?php register_taxonomy( $taxonomy, $object_type, $args ); ?>

$object_type (array/string) (required) Name of the object type for the taxonomy object. Object-types can be built-in Post Type or any Custom Post Type that may be registered.

Builtin Post Types:

  • post

  • page

  • attachment
  • revision
  • nav_menu_item.

Custom Post Types:

  • {custom_post_type} - Custom Post Type names must be all in lower-case and without any spaces.

  • null - Setting explicitly to null registers the taxonomy but doesn't associate it with any objects, so it won't be directly available within the Admin UI. You will need to manually register it using the 'taxonomy' parameter (passed through $args) when registering a custom post_type (see register_post_type()), or using register_taxonomy_for_object_type().

Take a look here if you want to code:

http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress

There are also plugins inspired by that post. Also, a massive open source plugin that goes even further is Groups:

https://github.com/itthinx/groups

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736262118a792.html

最新回复(0)