WordPress.org

Support

Support » Plugins and Hacks » how to call my register custom post type function in my main plugin file

how to call my register custom post type function in my main plugin file

  • Hello Guys,

    Can you help me on how can I solved this.
    I have 3 files:
    wp_hotel.php – main plugin file
    wp_hotel-admin.php – for creating admin menus in wordpress dashboard
    wp_hotel-post-type.php -for creating the custom post type

    now the code to call my 2 file in my wp_hotel.php is

    add_action('admin_menu', array('CPHotel_Admin', 'admin_menu'));
    add_action('admin_init', array('CPHotel_PostType', 'custom_post_type'));

    Creating the admin menus in the dashboard works fine, but creating the post type doesn’t work

    the custom_post_type() function in my CPHotel_PostType class in wp_hotel-post-type.php is this:

    public static function custom_post_type(){
      add_action('init','register_hotel_post_type');
      add_action('init','register_hotel_metabox');
      add_action('init','register_hotel_taxonomy');
    }

    my codes in register_hotel_post_type

    public function register_hotel_post_type(){
       $args = array(
       'labels' => array(
       'name' => 'Hotel Rooms',
       'singular_name' => 'Hotel Room',
       'add_new' => 'Add New Hotel Room',
       'add_new_item' => 'Add New Hotel Room',
       'edit_item' => 'Edit Hotel Room',
       'new_item' => 'Add New Hotel Room',
       'view_item' => 'View Hotel Room',
       'search_items' => 'Search Hotel Rooms',
       'not_found' => 'No Hotel Rooms Found',
       'not_found_in_trash' => 'No Hotel Rooms Found in Trash'),
       'query_var' => 'cphotelroom',
       'rewrite' => array('slug' => 'cphotelroom/',),
       'public' => true,
       menu_icon' => plugins_url('wp_customhotelbooking/assets/img/home16.png', __FILE__),
       'supports' => array('title','thumbnail','editor','excerpt','page-attributes',));
       register_post_type('cphotelroom',$args);
    }

    How can I Fixed this….please help…

  • The topic ‘how to call my register custom post type function in my main plugin file’ is closed to new replies.