Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 exapmle?

Thanks you.

share|improve this question
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? –  MikeSchinkel Feb 10 '11 at 15:05
1  
@mha - Also, I notice your "accept rate" is 0% meaning you've asked several questions but have "accepted" none of the answers yet. You are likely to get more people to answer your new questions if you accept answers to your prior questions and thus give the people who made the effort to answer points for their efforts. –  MikeSchinkel Feb 10 '11 at 15:36
1  
5 questions and a 0% accept rate? No thanks. –  John P Bloch Feb 10 '11 at 16:39
    
I was about to respond, but yeah -- not cool, I'll pass. –  editor Feb 11 '11 at 0:37
    
@MikeSchinkel @editor @John P Bloch I am extremely sorry for my accept rate as I am totally new in this community I did not know how to accept answers. Now I am learning little bit. I will be very grateful if you help me. –  mha Mar 7 '11 at 11:10

2 Answers 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.

share|improve this answer
    
Can you please help me how can I do that? Whit some code example? –  mha Mar 7 '11 at 11:25

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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