treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Help With WP Custom Post Types

  • I'm getting this error in my WordPress dashboard which has to do with the custom post type I've got set up.

    "Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'admin_init' not found or invalid function name in /nfs/c03/h01/mnt/81147/domains/bitthirsty.com/html/wp-includes/plugin.php on line 406"

    This is how my custom post type is set up in functions.php file:

    add_action('init', 'lists_register');
    
    function lists_register() {
    
      $labels = array(
        'name' => _x('Lists', 'post type general name'),
        'singular_name' => _x('List', 'post type singular name'),
        'add_new' => _x('Add New', 'list item'),
        'add_new_item' => __('Add New List'),
        'edit_item' => __('Edit List'),
        'new_item' => __('New List'),
        'view_item' => __('View List'),
        'search_items' => __('Search Lists'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
      );
    
      $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail')
        ); 
    
      register_post_type( 'lists' , $args );
      }
    
      add_action("admin_init", "admin_init");
    
      global $post;
    
      add_action('save_post', 'save_details');
    

    Any idea what could be the problem?

    Any help would be appreciated.

    Thanks in advance!