Skip to content

Instantly share code, notes, and snippets.

@wpspeak
Last active April 16, 2019 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpspeak/5997576 to your computer and use it in GitHub Desktop.
Save wpspeak/5997576 to your computer and use it in GitHub Desktop.
Create a simple Portfolio Custom Post Type
<?php
// Create portfolio custom post type
add_action( 'init', 'register_cpt_portfolio' );
function register_cpt_portfolio() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'portfolio' ),
'singular_name' => __( 'Portfolio', 'portfolio' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'public' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment