Warning when attempting to edit/add custom post type

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

1 Answer
1

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

Leave a Comment