Skip to content

Instantly share code, notes, and snippets.

@KustomDeveloper
Last active December 4, 2017 19:47
Show Gist options
  • Save KustomDeveloper/fcf971d8cca2afad6ce7ced921cfcbe2 to your computer and use it in GitHub Desktop.
Save KustomDeveloper/fcf971d8cca2afad6ce7ced921cfcbe2 to your computer and use it in GitHub Desktop.
<?
// Add at bottom of functions.php file
//Example with minimum options
function create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true,
)
);
}
add_action( 'init', 'create_post_type' );
/*-----------------------------------------------------*/
// Add at bottom of functions.php file
//Example with multiple options
add_action( 'init', 'register_movie' );
function register_movie() {
$labels = array(
'name' => 'Movies',
'singular_name' => 'Movie',
'add_new' => 'Add New',
'add_new_item' => 'Add New Movie',
'edit_item' => 'Edit Movie',
'new_item' => 'New Movie',
'view_item' => 'View Movie',
'search_items' => 'Search Movies',
'not_found' => 'No movies found',
'not_found_in_trash' => 'No movies found in Trash',
'menu_name' => 'Movies',
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'description' => 'Here you will add all the movies for the database',
'supports' => array( 'title', 'editor', 'thumbnail' ),
'taxonomies' => array( 'genre', 'movies', 'year' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
//'menu_icon' => '/path/to/icon.png',
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'movie', $args );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment