1

How can I show only terms by id or slug on edit-tags.php (custom taxonomy manage page) for a custom taxonomy.

I am saving term_owner metadata to a table for each term and getting all terms' ids for a specific term_owner. Now I want to show only these terms on edit-tags.php.

I have tried list_terms_exclusions filter but seems it doses not work for edit-tags.php?taxonomy={custom_taxonomy_name} or I am missing something.

Can anyone help me with a working example?

Thanks you.

3
  • 1
    @mha When you ask "How can I show only terms by id or slug" would it mean the same to ask "How can I filter terms by id or slug?" As written I'm not sure if that is what you mean or not. Also, you can post the code you have but you are saying is not working? Commented Feb 10, 2011 at 15:05
  • I was about to respond, but yeah -- not cool, I'll pass.
    – editor
    Commented Feb 11, 2011 at 0:37
  • @mha - No worries, it can be non-obvious. Glad to have you on board. Commented Mar 7, 2011 at 23:50

2 Answers 2

2

The edit-tags.php doesn't listen to any arguments except the s search query variable. If you want to do anything more advanced, you will have to hook into the get_terms filter.

1
  • Can you please help me how can I do that? Whit some code example?
    – mha
    Commented Mar 7, 2011 at 11:25
0

I have added these code to my theme function.php for my custom taxonomy "series".


add_filter('edited_terms', 'mysite_edited_terms');
function mysite_edited_terms($term_id) {
  if($_POST['taxonomy'] == 'series'): {
    $user = wp_get_current_user();
    if ($user->ID) {
      $terms = get_user_meta($user->ID,'users_terms_for_series');
      $terms = (empty($terms) ? $term_id : "{$terms},{$term_id}");
      update_user_meta($user->ID,'users_terms_for_series',$terms);
    }
  }
}

add_filter('list_terms_exclusions', 'my_list_terms_exclusions', 10, 2);
function my_list_terms_exclusions( $exclusions, $args ) {
  global $pagenow;
  if (current_user_can('can_manage_all_terms') && 
    $pagenow=='edit-tags.php?taxonomy=series') {
    $terms = get_user_meta($user->ID,'users_terms_for_series');
    $exclusions = " {$exclusions} AND t.ID NOT IN ({$terms})";
  }
  return $exclusions;
}

but nothing happened. This code is based on @MikeSchinkel. I think @Jan Fabry is right that the edit-tags.php doesn't listen to any arguments. But I dont no how to do that.

Any help will be greatly appreciated. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.