Skip to content

Instantly share code, notes, and snippets.

@morgyface
Last active January 22, 2019 17:53
Show Gist options
  • Select an option

  • Save morgyface/7de99c7feb980977b056c3f1e0d1e028 to your computer and use it in GitHub Desktop.

Select an option

Save morgyface/7de99c7feb980977b056c3f1e0d1e028 to your computer and use it in GitHub Desktop.
WordPress | Add a custom post type
<?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' );
?>
@morgyface
Copy link
Author

morgyface commented Aug 24, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment