Skip to content

Instantly share code, notes, and snippets.

@domantasg
Created September 22, 2017 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domantasg/21b717f6b21ca5b9b22988be21406546 to your computer and use it in GitHub Desktop.
Save domantasg/21b717f6b21ca5b9b22988be21406546 to your computer and use it in GitHub Desktop.
// The custom function MUST be hooked to the init action hook
add_action( 'init', 'lc_register_movie_post_type' );
// A custom function that calls register_post_type
function lc_register_movie_post_type() {
// Set various pieces of text, $labels is used inside the $args array
$labels = array(
'name' => _x( 'Movies', 'post type general name' ),
'singular_name' => _x( 'Movie', 'post type singular name' ),
...
);
// Set various pieces of information about the post type
$args = array(
'labels' => $labels,
'description' => 'My custom post type',
'public' => true,
...
);
// Register the movie post type with all the information contained in the $arguments array
register_post_type( 'movie', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment