0

I've just moved my WP site from one server to another and my custom post type plugin is causing the following error:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'my_admin' not found or invalid function name in /var/sites/*/******.com/public_html/wp-includes/plugin.php on line 496

My code for the custom post types is as follows:

function all_post_types() {
    create_video_camera();
    create_stills_camera();
    create_lens();
    create_light();
    create_sound();
    create_aerial();
}

add_action( 'init', 'all_post_types' );

function create_video_camera() {

    $labels = array(
        'name'                => _x( 'Video Cameras', 'Post Type General Name', '******' ),
        'singular_name'       => _x( 'Video Camera', 'Post Type Singular Name', '******' ),
        'menu_name'           => __( 'Video Camera', '******' ),
        'name_admin_bar'      => __( 'Video Camera', '******' ),
        'parent_item_colon'   => __( 'Parent Video Camera:', '******' ),
        'all_items'           => __( 'All Video Cameras', '******' ),
        'add_new_item'        => __( 'Add New Video Camera', '******' ),
        'add_new'             => __( 'Add New', '******' ),
        'new_item'            => __( 'New Video Camera', '******' ),
        'edit_item'           => __( 'Edit Video Camera', '******' ),
        'update_item'         => __( 'Update Video Camera', '******' ),
        'view_item'           => __( 'View Video Camera', '******' ),
        'search_items'        => __( 'Search Video Camera', '******' ),
        'not_found'           => __( 'Not found', '******' ),
        'not_found_in_trash'  => __( 'Not found in Trash', '******' ),
    );
    $args = array(
        'label'               => __( 'video_camera', '******' ),
        'description'         => __( 'Video Camera Template', '******' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'thumbnail', ),
        'taxonomies'          => array( 'category', 'post_tag' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'menu_position'       => 25,
        'menu_icon'           => 'dashicons-video-alt',
        'show_in_admin_bar'   => true,
        'show_in_nav_menus'   => true,
        'can_export'          => true,
        'has_archive'         => true,      
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'post',
    );
    register_post_type( 'video_camera', $args );

}

with the other register_post_type functions being largely similar.

It all worked perfectly on the old server, but now I'mm getting the error. I've tried other solutions, but with no luck.

Thanks in advance :)

5
  • 2
    Can you find a my_admin function anywhere in your code, or any references to it? Try looking across the entire codebase, not just the parts you've coded – Tom J Nowell Aug 17 '15 at 14:29
  • As @TomJNowell suggests, the code above does not contain my_admin function calling, so there is no problem (in that particular code). – Marek Aug 17 '15 at 15:32
  • I do use the code add_action( 'admin_init', 'my_admin' ); at the bottom of the file. It's weird, because I just copied everything across form the other server and it suddenly became a problem. – FMJ Aug 17 '15 at 16:18
  • you should remove that then, unless there's a longer version on your old server with the definition of my_admin – Tom J Nowell Aug 17 '15 at 16:23
  • I deleted it, and the custom post types dissipated. I changed it to my_admin to all_post_types and the error vanished. It all looks the same on the old server, so it must have been running off magic. Anyway, thanks for your help. – FMJ Aug 17 '15 at 16:34
0

The code contained the line add_action( 'admin_init', 'my_admin' ); at the end, but my_admin wasn't declared anywhere. Changed it to all_post_types, my function to register all the custom post types at once and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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