No custom post types appearing in admin menu
-
I’m building my first plugin, and attempting to register three custom post types in my setup_post_types() function. Within that function, I’m using the register_post_type function, exactly as instructed in the codex (see code below). However, when I activate my plugin, the post types that I registered are not appearing anywhere. My entire plugin consists of one file right now, so what you see below is everything (minus the commented meta data for all plugins).
add_action( 'init', 'setup_post_types' ); function setup_post_types() { // Register our "appointment" custom post type $appt_labels = array( 'name' => __('Appointments'), 'singular_name' => __('Appointment'), 'menu_name' => __('My Appointments'), 'name_admin_bar' => __('New Appointment'), 'all_items' => __('View All Appointments'), 'add_new' => __('Book New Appointment'), 'add_new_item' => __('Book New Appointment'), 'edit_item' => __('Update Appointment'), 'new_item' => __('Book New Appointment'), 'view_item' => __('Preview this Appointment'), 'search_items' => __('Search My Appointments'), 'not_found' => __('No Appointments Found'), 'not_found_in_trash' => __('No Appointments found in Trash') ); $appt_args = array( 'labels' => $appt_labels, 'public' => 'true', 'show_ui' => 'true', 'show_in_menu' => 'true', 'show_in_admin_bar' => 'true', 'menu_position' => 23, 'menu_icon' => 'dashicons-backup', 'rewrite' => array('slug' => 'appts'), 'has_archive' => true ); register_post_type('whattimeagain_appt', $appt_args); // Register our "vendor" custom post type $vendor_labels = array( 'name' => __('Vendors'), 'singular_name' => __('Vendor'), 'menu_name' => __('My Vendors'), 'name_admin_bar' => __('Add Vendor'), 'all_items' => __('All Vendors'), 'add_new' => __('Add New Vendor'), 'add_new_item' => __('Add New Vendor'), 'edit_item' => __('Update Vendor Information'), 'new_item' => __('Add New Vendor'), 'view_item' => __('Preview Vendor Information'), 'search_items' => __('Search My Vendors'), 'not_found' => __('Vendor not Found'), 'not_found_in_trash' => __('Vendor not found in Trash') ); $vendor_args = array( 'labels' => $vendor_labels, 'public' => 'true' , 'show_ui' => 'true', 'show_in_menu' => 'true', 'show_in_admin_bar' => 'true', 'menu_position' => 21, 'menu_icon' => 'dashicons-businessman', 'rewrite' => array('slug' => 'vendors'), 'has_archive' => true ); register_post_type('whattimeagain_vend', $vendor_args); // Register our "customer" custom post type $customer_labels = array( 'name' => __('Customers'), 'singular_name' => __('Customer'), 'menu_name' => __('My Customers'), 'name_admin_bar' => __('Add Customer'), 'all_items' => __('All Customers'), 'add_new' => __('Add New Customer'), 'add_new_item' => __('Add New Customer'), 'edit_item' => __('Update Customer Information'), 'new_item' => __('Add New Customer'), 'view_item' => __('Preview Customer Information'), 'search_items' => __('Search My Customers'), 'not_found' => __('Customer not Found'), 'not_found_in_trash' => __('Customer not found in Trash') ); $customer_args = array( 'labels' => $customer_labels, 'public' => 'true', 'show_ui' => 'true', 'show_in_menu' => 'true', 'show_in_admin_bar' => 'true', 'menu_position' => 22, 'menu_icon' => 'dashicons-groups', 'rewrite' => array('slug' => 'customers'), 'has_archive' => true ); register_post_type('whattimeagain_cust', $customer_args); } function activate() { // Trigger our function that registers the custom post type setup_post_types(); // Clear the permalinks after the post type has been registered flush_rewrite_rules(); } function deactivate() { // Our post type will be automatically removed, so no need to unregister it // Clear the permalinks to remove our post type's rules flush_rewrite_rules(); } register_activation_hook(__FILE__, 'activate'); register_deactivation_hook(__FILE__, 'deactivate');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘No custom post types appearing in admin menu’ is closed to new replies.