Last active
January 22, 2019 17:53
-
-
Save morgyface/7de99c7feb980977b056c3f1e0d1e028 to your computer and use it in GitHub Desktop.
WordPress | Add a custom post type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Add the custom post type | |
| function create_post_type() { | |
| register_post_type( 'kit-lists', | |
| array( | |
| 'labels' => array( | |
| 'name' => __( 'Kit Lists' ), | |
| 'singular_name' => __( 'Kit List' ) | |
| ), | |
| 'public' => true, | |
| 'has_archive' => true, | |
| 'rewrite' => array('slug' => 'kit-lists'), | |
| 'menu_position' => 22, | |
| 'menu_icon' => 'dashicons-admin-customizer', | |
| 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ) | |
| ) | |
| ); | |
| } | |
| add_action( 'init', 'create_post_type' ); | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More than pages and posts
Add the above to your theme's functions.php file to add an additional, custom, post type. In this instance we're creating a post-type called "kit-lists".
See the WordPress.org Dashicons section for more menu icons. Change "dashicons-admin-customizer" for the name of the icon you'd like to use.