How to create a custom post type

The fist sptep is to get access to the file functions.phm in our wordpress installation

/*

  • Creating a function to create our CPT
    */

function custom_post_type() {

// Set UI labels for Custom Post Type
$labels = array(
‘name’ => x( ‘Movies’, ‘Post Type General Name’, ‘minimalist-stories’ ), ‘singular_name’ => _x( ‘Movie’, ‘Post Type Singular Name’, ‘minimalist-stories’ ), ‘menu_name’ => ( ‘Movies’, ‘minimalist-stories’ ), ‘parent_item_colon’ => ( ‘Parent Movie’, ‘minimalist-stories’ ), ‘all_items’ => ( ‘All Movies’, ‘minimalist-stories’ ), ‘view_item’ => ( ‘View Movie’, ‘minimalist-stories’ ), ‘add_new_item’ => ( ‘Add New Movie’, ‘minimalist-stories’ ), ‘add_new’ => ( ‘Add New’, ‘minimalist-stories’ ), ‘edit_item’ => ( ‘Edit Movie’, ‘minimalist-stories’ ), ‘update_item’ => ( ‘Update Movie’, ‘minimalist-stories’ ), ‘search_items’ => ( ‘Search Movie’, ‘minimalist-stories’ ), ‘not_found’ => ( ‘Not Found’, ‘minimalist-stories’ ), ‘not_found_in_trash’ => _( ‘Not found in Trash’, ‘minimalist-stories’ ),
);

// Set other options for Custom Post Type

$args = array(
    'label'               => __( 'movies', 'minimalist-stories' ),
    'description'         => __( 'Movie news and reviews', 'minimalist-stories' ),
    'labels'              => $labels,
    // Features this CPT supports in Post Editor
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
    // You can associate this CPT with a taxonomy or custom taxonomy. 
    'taxonomies'          => array( 'genres' ),
    /* A hierarchical CPT is like Pages and can have
    * Parent and child items. A non-hierarchical CPT
    * is like Posts.
    */
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'post',
    'show_in_rest' => true,

);

// Registering your Custom Post Type
register_post_type( 'movies', $args );

}

/* Hook into the ‘init’ action so that the function

  • Containing our post type registration is not
  • unnecessarily executed.
    */

add_action( ‘init’, ‘custom_post_type’, 0 );