WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ). :-)

share|improve this question

closed as too localized by kaiser, toscho Apr 17 '12 at 2:05

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Helped, but close voted as typos won't help. – kaiser Apr 17 '12 at 1:36
Thanks Kaiser! Now can you also delete it entirely :-) – Niels Apr 17 '12 at 5:02
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 at 21:19
up vote 7 down vote accepted

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

share|improve this answer
This helped a lot! Thanks man :-) – MindTooth Jun 28 at 17:34
Great catch Kaiser. – jdm2112 Jul 21 at 21:20

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