How Do I Create a Custom Post Type Menu in WordPress?
Creating a custom post type menu in WordPress is a fairly straightforward process. The first step is to create a new file in your theme directory called user_post_types.
php. This file should contain the following lines:.
__( ‘My Custom Post Type’, ‘wpbakery’ ), ‘description’ => __( ‘Custom post type to manage posts of a specific type’, ‘wpbakery’ ), ‘public’ => true, ‘rewrite’ => array( ‘slug’ => ‘my-custom-post-type’, ‘to’ => ‘/my-custom-post-type/’, ), ‘taxonomies’ => array( ‘my-custom-post-type’ ), ‘menu_icon’ => ‘icon-wp-post-type-my-custom-post-type’, ‘ menu_order’ => ‘post-type-menu’, ‘has_archive’ => true, ‘has_term’ => true, ‘menu_icon_class’ => ‘wp-post-type-has-term’, ), ); }
The first line of this file will activate the WordPress custom post type menu. The second line registers our custom post type with the WordPress platform. Next, we need to add some values to our custom post type definition.
We’ll need to provide a label for our post type, a description of what our post type is, whether or not it is public, and the list of taxonomies that our post type will be available in. We also need to provide the slug for our post type and the path to our post type on the WordPress platform.
We also need to provide some values for the custom post type menu. We need to provide the path to our post type on the WordPress platform, the name of our post type, and the class that we want to use for our post type menu icon.
Finally, we need to specify whether or not our post type has an archive and whether or not it has a term.