Warning: Cannot modify header information - headers already sent by (output started at /home/n742ef5/public_html/forum/index.php:3) in /home/n742ef5/public_html/forum/wp-content/plugins/asgaros-forum/includes/forum-online.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /home/n742ef5/public_html/forum/index.php:3) in /home/n742ef5/public_html/forum/wp-content/plugins/asgaros-forum/includes/forum-unread.php on line 43

Warning: Cannot modify header information - headers already sent by (output started at /home/n742ef5/public_html/forum/index.php:3) in /home/n742ef5/public_html/forum/wp-content/plugins/asgaros-forum/includes/forum-unread.php on line 82
How to create a custom post type Step 1 – Sithtamil – My Notes

Forum

Please or Register to create posts and topics.

How to create a custom post type Step 1

  • 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
*/

 

The Make custom post type name  Movies

  1. Copy of codes from
  2. https://developer.wordpress.org/reference/functions/register_post_type/#uses
  3. 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 );
}