2

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?

6

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.

  • Na not genius just checked it properly ;) – sven Mar 22 '14 at 10:59
  • 1
    Please - take the "genius" compliment. Makes me feel like less of a goose for making such a silly and simple mistake. – Luke Stevenson Mar 23 '14 at 3:34
  • Happens all the time :), nothing so big..! – sven Mar 23 '14 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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