2

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' );
7
  • 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
    Commented Jul 11, 2011 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
    Commented Jul 11, 2011 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
    Commented Jul 11, 2011 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
    Commented Jul 11, 2011 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
    Commented Jul 11, 2011 at 5:19

1 Answer 1

1

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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