How to create a custom post type Step 1
Quote from admin on April 24, 2020, 3:27 pm
- Create a folder in plugin folder Name ; wp-custom-post-type
- Create a file name called ; wp-custom-post-type.php
And then Initialize the plugin and author name
/*
Plugin Name: WP Custom Post Type
Description: This is a simple plugin for purpose of learning about wordpress CPT
Version: 1.0.0
Author: Thava
*/
- Create a folder in plugin folder Name ; wp-custom-post-type
- Create a file name called ; wp-custom-post-type.php
And then Initialize the plugin and author name
/*
Plugin Name: WP Custom Post Type
Description: This is a simple plugin for purpose of learning about wordpress CPT
Version: 1.0.0
Author: Thava
*/
Quote from admin on April 24, 2020, 3:29 pmThe Make custom post type name Movies
- Copy of codes from
- https://developer.wordpress.org/reference/functions/register_post_type/#uses
- and then change book --> movie and then remove textdomain
add_action( 'init', 'wpl_owt_cpt_register_movies' );
function wpl_owt_cpt_register_movies() {
$labels = array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' ),
'menu_name' => __( 'Movies' ),
'name_admin_bar' => __( 'Movie' ),
'add_new' => __( 'Add New'),
'add_new_item' => __( 'Add New Movie' ),
'new_item' => __( 'New Movie' ),
'edit_item' => __( 'Edit Movie' ),
'view_item' => __( 'View Movie' ),
'all_items' => __( 'All Movies' ),
'search_items' => __( 'Search Movies' ),
'parent_item_colon' => __( 'Parent Movies:' ),
'not_found' => __( 'No Movies found.' ),
'not_found_in_trash' => __( 'No Movies found in Trash.' )
);$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'Movie' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail' ),
);register_post_type( 'Movie', $args );
}
The Make custom post type name Movies
- Copy of codes from
- https://developer.wordpress.org/reference/functions/register_post_type/#uses
- and then change book --> movie and then remove textdomain
add_action( 'init', 'wpl_owt_cpt_register_movies' );
function wpl_owt_cpt_register_movies() {
$labels = array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' ),
'menu_name' => __( 'Movies' ),
'name_admin_bar' => __( 'Movie' ),
'add_new' => __( 'Add New'),
'add_new_item' => __( 'Add New Movie' ),
'new_item' => __( 'New Movie' ),
'edit_item' => __( 'Edit Movie' ),
'view_item' => __( 'View Movie' ),
'all_items' => __( 'All Movies' ),
'search_items' => __( 'Search Movies' ),
'parent_item_colon' => __( 'Parent Movies:' ),
'not_found' => __( 'No Movies found.' ),
'not_found_in_trash' => __( 'No Movies found in Trash.' )
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'Movie' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail' ),
);
register_post_type( 'Movie', $args );
}