Using get_terms() in admin interface from a plugin?
-
Hi,
I’m writing a plugin where I’m using custom (user) taxonomies to add custom fields to a user profile, editable in the admin interface for that user. So, for example, I’ve registered a custom taxonomy called “member-status”.
I can manage my custom taxonomies fine — I can add new terms, add translations, etc. And on the admin pages for the taxonomies, I can use the language selector in the admin bar to view only English terms, only Japanese terms, and so on.
I’ve now added a show_user_profile filter so I can add a list of “member-status” terms on each user profile page, and tried to get hold of the terms like this in my filter code:
$terms = get_terms($key, array('hide_empty'=>false));
(
$key
is my taxonomy slug, e.g. ‘member-name’)But that gets me back all the terms, in all languages. I was expecting
get_terms
to respond to the language selector in the admin bar — when I choose English in the language selector, I still get all the terms.I’ve experimented by doing this, which I thought would manually select the English terms only:
$terms = get_terms($key, array('hide_empty'=>false, 'lang' => 'en'));
…but even then, I still get all the taxonomy terms, for all languages.
Any hints? I’m using WP3.7.1, Polylang 1.2.1.
Thanks,
Matt
- The topic ‘Using get_terms() in admin interface from a plugin?’ is closed to new replies.