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.

I am trying to add a custom column to the tables shown on the Tags & Categories admin pages in Wordpress.

I have created a function, and added it as a filter using

add_filter( 'manage_post_tag_custom_column' , 'my_custom_column' , 10 , 2 );

My function is

my_custom_column( $out , $name , $term_id ){
  switch( $name ){
    case 'my_column_slug' :
      echo '<pre>';var_dump( func_get_args() );echo '</pre>';
      break;
  }
}

My column is shown in the table, with the <pre>...</pre> content, but it seems that no $term_id is being passed to my function.

array(2) {
  [0]=>
  string(0) ""
  [1]=>
  string(12) "my_column_slug"
}

I have referred to a number of resources to confirm that there should be three arguments passed to the function (including this StackExchange article). Am I missing something here?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You are using wrong number of arguments in add_filter, you specified to get 2 arguments and you are looking for third one:

Update your add_filter code to this:

add_filter( 'manage_post_tag_custom_column' , 'my_custom_column' , 10 , 3 );

The 3 in the end tells the filter to provide all the three arguments to your function.

share|improve this answer
    
You sir, are a genius. Thank you! –  Lucanos Mar 22 at 6:49
    
Na not genius just checked it properly ;) –  sven Mar 22 at 10:59
    
Please - take the "genius" compliment. Makes me feel like less of a goose for making such a silly and simple mistake. –  Lucanos Mar 23 at 3:34
    
Happens all the time :), nothing so big..! –  sven Mar 23 at 7:15
add comment

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.