I think this may be more of a general php question but I am posting it here as it relates to a WP function. I am having some issues with an add_action on manage_posts_custom_column inside a class. Here is the code (stripped a little):

class The_class{

    function __construct() {

    function add_actions() {
        add_action('admin_notices', array($this, 'admin_notices'));
        add_action('manage_posts_custom_column', array($this, 'manage_post_columns', 10, 2));

    function admin_notices() {
    // Works fine

    function manage_post_columns($column_name, $post_id)
        switch ($column_name) {
            case 'xxxyyzz':
                // The code                                 
                // Error

The error I am getting is Warning: call_user_func_array() expects parameter 1 to be a valid callback, array must have exactly two members in xxx/wp-includes/plugin.php on line 405.

Looking deeper I found that the action manage_posts_custom_column is referenced in the WP_Posts_List_Table class that extends WP_List_Table and I wonder if this is the cause of the error?

How do I get around this?


Well for starters I could write the action properly!!! Instead of add_action('manage_posts_custom_column', array($this, 'manage_post_columns', 10, 2)); it should be add_action('manage_posts_custom_column', array($this, 'manage_post_columns'), 10, 2);. Note the position of the ). :-)

  • Helped, but close voted as typos won't help.
    – kaiser
    Apr 17 '12 at 1:36
  • 1
    Actually - this isn't as localized an issue as some of us would like to admit. After wasting 20 minutes on this I found Niels question and edit VERY helpful as I had made the same mistake.
    – jdm2112
    Jul 21 '16 at 21:19

Your problem is a simple typo:

array($this, 'manage_post_columns', 10, 2)


array($this, 'manage_post_columns'), 10, 2

I guess you see the difference

  • 1
    Great catch Kaiser.
    – jdm2112
    Jul 21 '16 at 21:20

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