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' );
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.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.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.