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 have two custom post types in my WordPress installation. Both are set up the same way in functions.php (one called "Media" and the other "Testimonials"). For some reason, I'm now getting the following error in Admin when I go to edit or add Media items:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'add_media_metaboxes' not found or invalid function name in /home/user /public_html/wp-includes/plugin.php on line 405

This does not affect my ability to add or edit Media items. Why is this error occurring, and how can I get rid of the warning?

The site just changed domains, but I can't see how that would affect one custom post type and not the other. I've updated permalinks and all internal and external links.

Thanks.


To follow up on @pippin's answer, here's the full code from functions.php. Do you see an error here?

function wpt_media_posttype() {
    register_post_type( 'media',
        array(
            'labels' => array(
                'name' => __( 'Media Items' ),
                'singular_name' => __( 'Media Item' ),
                'add_new' => __( 'Add New Media Item' ),
                'add_new_item' => __( 'Add New Media Item' ),
                'edit_item' => __( 'Edit Media Items' ),
                'new_item' => __( 'Add New Media Item' ),
                'view_item' => __( 'View Media Items' ),
                'search_items' => __( 'Search Media' ),
                'not_found' => __( 'No media items found' ),
                'not_found_in_trash' => __( 'No media items found in trash' )
            ),
            'public' => true,
            'supports' => array( 'editor', 'thumbnail', 'title' ),
            'capability_type' => 'post',
            'rewrite' => array("slug" => "media"), // Permalinks format
            'has_archive' => true,
            'menu_position' => 5,
            'register_meta_box_cb' => 'add_media_metaboxes'
        )
    );
}

add_action( 'init', 'wpt_media_posttype' );
share|improve this question
    
Is there a add_media_metaboxes function defined anywhere? Most likely not. My guess is that when you transferred the site, that function did not make it over. –  tollmanz Jul 11 '11 at 1:10
2  
Trying adding this to your functions.php file: function add_media_metaboxes(){}. If the error disappears, we know the problem is that that function is missing. You need to find your original files and copy that function back into your functions.php file. –  tollmanz Jul 11 '11 at 1:11
    
@tollmanz, you're a genius. This worked. I just wish I knew why. My understanding of custom post types diminishes by the minute. –  user5486 Jul 11 '11 at 2:10
    
Your last argument of the register_post_type function defines a callback function to add meta_boxes. The system tried to run that function, but it was missing. You should probably check to see if there should be metaboxes added to your post type. There probably is something missing. –  tollmanz Jul 11 '11 at 3:02
    
@tollmanz, this is a result of my attempt to cobble together the many tutorials on custom post types/metaboxes without fully understanding how they work. As you suggested, this custom post type doesn't have any extra metaboxes -- just title and editor fields. Should I eliminate the 'register_meta_box_cb' line entirely? –  user5486 Jul 11 '11 at 5:19

1 Answer 1

Check your add_media_metaboxes() function. The first parameter is wrong and mostly likely just miss spelled.

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.