wordpress create new post type

/*
* 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', 'twentytwenty' ),
        'singular_name'       => _x( 'Movie', 'Post Type Singular Name', 'twentytwenty' ),
        'menu_name'           => __( 'Movies', 'twentytwenty' ),
        'parent_item_colon'   => __( 'Parent Movie', 'twentytwenty' ),
        'all_items'           => __( 'All Movies', 'twentytwenty' ),
        'view_item'           => __( 'View Movie', 'twentytwenty' ),
        'add_new_item'        => __( 'Add New Movie', 'twentytwenty' ),
        'add_new'             => __( 'Add New', 'twentytwenty' ),
        'edit_item'           => __( 'Edit Movie', 'twentytwenty' ),
        'update_item'         => __( 'Update Movie', 'twentytwenty' ),
        'search_items'        => __( 'Search Movie', 'twentytwenty' ),
        'not_found'           => __( 'Not Found', 'twentytwenty' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'twentytwenty' ),
    );
     
// Set other options for Custom Post Type
     
    $args = array(
        'label'               => __( 'movies', 'twentytwenty' ),
        'description'         => __( 'Movie news and reviews', 'twentytwenty' ),
        '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 );

4.22
9
Sanchises 130 points

                                    /*
- The function you want for creating a custom wordpress post type is 
register_post_type()
- https://developer.wordpress.org/reference/functions/register_post_type/
- To add more meta boxes to the post type search for the support items in the 
above link.
- Below is a basic implementation of the function to register video post type
*/
register_post_type( 'video',
  array(
    'labels' => array(
      'name' => 'Videos',
      'singular_name' => 'Video'
    ),
    'public' => true,
    'has_archive' => true,
    'rewrite' => array(
      'slug' => 'videos'
    ),
    'exclude_from_search'=> true
    ,
    'supports' => array(
      'title','editor','thumbnail'
    )
  )
);

4.22 (9 Votes)
0
4.75
4
Cowang 80 points

                                    function custom_post_type() {
     $labels = array(
        'name'                => _x( 'Movies', 'Post Type General Name', 'twentythirteen' ),
        'singular_name'       => _x( 'Movie', 'Post Type Singular Name', 'twentythirteen' ),
        'menu_name'           => __( 'Movies', 'twentythirteen' ),
        'parent_item_colon'   => __( 'Parent Movie', 'twentythirteen' ),
        'all_items'           => __( 'All Movies', 'twentythirteen' ),
        'view_item'           => __( 'View Movie', 'twentythirteen' ),
        'add_new_item'        => __( 'Add New Movie', 'twentythirteen' ),
        'add_new'             => __( 'Add New', 'twentythirteen' ),
        'edit_item'           => __( 'Edit Movie', 'twentythirteen' ),
        'update_item'         => __( 'Update Movie', 'twentythirteen' ),
        'search_items'        => __( 'Search Movie', 'twentythirteen' ),
        'not_found'           => __( 'Not Found', 'twentythirteen' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'twentythirteen' ),
    );
     
     
    $args = array(
        'label'               => __( 'movies', 'twentythirteen' ),
        'description'         => __( 'Movie news and reviews', 'twentythirteen' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
        'hierarchical'        => true,
        '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'     => 'page',
        'show_in_rest'        => true,
         
        // This is where we add taxonomies to our CPT
        'taxonomies'          => array( 'category' ),
    );
     
    // Registering your Custom Post Type
    register_post_type( 'movies', $args );
 
}
 

add_action( 'init', 'custom_post_type', 0 );

4.75 (4 Votes)
0
3.5
2
Sr.Bungle 85 points

                                    function create_posttype() {
  register_post_type( 'wpll_product',
    array(
      'labels' => array(
        'name' => __( 'Products' ),
        'singular_name' => __( 'Product' )
      ),
      'public' => true,
      'has_archive' => true,
      'rewrite' => array('slug' => 'products'),
    )
  );
}
add_action( 'init', 'create_posttype' );

3.5 (2 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
custom post type create code custom post type with custom category in wordpress HOW TO GET CUSTOME POST TYPE DATA wordpress create the custom post type custom post type wordpress demo how to use custom post type in wordpress How to create custom post type in WordPress step by-step tags in custom post type create "products" custom post type wordpress how to create custom post type in wordpress step by step wp code custom post type get post using custom post type how to get custom post type's tags how to get custom post type tags wordpress with custom post type add custom category to custom post type get custom post type post terms show post and custom post type on same category page in wordpress get custom post type category get custom post by type function to get the custom post type posts in wordpress custom post types and custom fields. wordpress get custom category of custom post type creating new post type add post_type wordpress doc add post_type wordpress wordpress register custom post type wp get custom post type category wordpress have_posts custom post type wp insert custom post type how to get custom post type custom post type category pages display custom post type in wordpress php Briefly explain what is a custom post type in WordPress. wp query custom post type category__in display category in custom post type how to get custom post type category name in wordpress create my own custom post type wordpress get custom post type by specific category in wordpress get custom post type by category in wordpress get custom post type by category name wordpress registering custom post types simple custom post type in wordpress custom post type have_posts wordpess custom post type custom post type page format custom post type html custome post type wordpress development add category to custom post type programmatically how to create custom post category in wordpress get custom post type page how to get custom post type by category id in wordpress how to get custom post type by category in wordpress wordpress add post to custom post type wordpress tag custom post type with another custom post type custom post type category query category custom post type wordpress add custom post type tag custom post type with custom field wordpress listing custom post type get post from custom post type insert custom post type wordpress POST TYPE custom functions custom post tye custom post type detail apge wordpress create custom post type with categories wordpress create custom post type with tags custom fields for custom post types custom post type custom variable custom post type custom attributes how to display custom post type page in wordpress create custom post type wordpress with options show custom post type posts get custom post type by post name custom post type terms what is a wordpress custom post types custom post type with custom fields add custom post type custom field wordpress php custom post type page in wordpress custom post types e custom post fields how to show custom post type category in wordpress wp "should i use" custom post type wp should i use custom post type custom post type tutorial custom post tyoe custom post type with custom fields wordpress custom post type options custom post type options wp add custom page on custom post type how create custom post type in wordpress custom post type insert post page for custom post type category custom post type with custom field code how to add category in custom post type wordpress create custom post type in a class create custom post type page wordpress wp is custom post type how to get custom post type category list in wordpress wordpress get custom post type all categories get custom post type categories wordpress what is custome post type in wordpress creating acustom post type wordpress insert post of custom post type how can create category to custom post type turn on custom post type custom post type category tags add categories in wordpress custom post type show custom post type in wordpress how to get custom post type field value wordpress template for custom post type category how to add category in post type code wordpress get posts custom post type query custom post type wordpress custom post type category list custom post type. create a custom post type wordpress tags on custom post type add custom fields in custom post type wordpress custom post type sub posts custom post type paged creating custom post types in wordpress wordpress custom post type how to custom post type post url create custom post type wordpress code wordpress make custom post type custom post type using custom template add custom post types wordpress how to create a custom post type in wordpress php get the category of custom post type by post id in wordpress popular post query custom post type wordpress popular post custom post type wordpress popular post custom posttype worpdress custom post type pages add Custom Post Type to custom post type wp code custom fields and post types is single custom post type register custom post type in wordpress how to create custom form in post type get the custom post type in wordpress Creating a basic custom post type content of custom post type post get post custom post type wordpress custom post custom field add custom post type support how to make a custom post type in wordpress custom field in custom post type add custom field using post type support wordpress custom post type supports category wordpress custome post type wordpress custom post type explained show category in custom post type create custome post type wordpress register custom post_type wordpress add custom post type in wordpress posts post type in posts wordpress custom post type code sample Register a custom post type wp create a custom post type custom post type class create a custom post type with a function add custom post type data in post wordpress how to display custom post type posts in wordpress add post type in posts wordpress wordpress add categories to custom post type how to create post type in wordpress where is my custom post type on database wordpress custom post type javascript how to add category for custom post type in wordpress admin how to create a new post type in wordpress wordpress create custom post type function.php creating a custom post type wordpress wordpress post type create category wordpress create post type generate custom post type add categories to custom post type wordpress custom post type post for a specific post wordpress wordpress insert custom post type custom post type category and tags custom post type category support add custom fields to custom post type how to display custom post type category wise in wordpress custom post types plugin create custom post type with category in wordpress custom post type parameters register custom post type in wordpress) generate wp custom post type what is custom post type in wordpress how to get custom post type category in wordpress wordpress add custom php to post type wordpress add custom php to custom post type wordpress add php to custom post type How to get custom post type in WordPress category in custom post type custom post types and custom fields custom post type tags how to create custom post type wp category page custom post type how to create custom post type category in wordpress custom post tupes Post Type create wordpress Post Type create wordpress custom post type with fields wordpress custom post type and fields set the_post custom post type how to display custom post type category in wordpress query how to add custom post type in wordpress custom post type definition wordpress display custom post type on page according to taxonom link custom post type wordpress category wordpress custom post type data tutorial custom post types wordpress php wordpress create post of custom post type display custom post type fields on custom posts in wordpress display custom post type fields on post in wordpress custom category custom post type custom post type show custom fields display custom post type category custom post types + wordpress create custom post type wordpress codex wp categories as custom post type custom post type post perpage custom post type as a page create custom field in post type add category in custom post type create a post type in wordpress get custom post type name custom post type categories functions terms of custom post tyoe create custom post category wordpress custom post type + wordpress custom post type category call in single.php wordpress add category to custom post type create custom post type category wordpress custom post type creation custom html in posttype html in custom posttype what can you put in custom posttype add new post type wordpress wordpress post new to custom post type add custom field in post type custom post type with categories reister custom post type wp custom post types wordpress php create custom post type custom post type to page how to call custom post type in wordpress update post of custom post type add a custom post type wordpress custom post type sample sample custom post type get custom post type fields add custom post type to category wordpress what is wordpress custom post type basic custom post type code wordpress create custom post type function how to add category and tag in custom post type in wordpress wp query custom post type wordpress php query custom post type wordpress php custom post type query wordpress generate custom post type wp insert post custom post type wordpress custom post type taxonomy category wordpress php Function custom post type template is_category() wordpress php template is_category() Function custom post type wordpress custom post type single get custom post type by custom taxonomy wp get custom post category wp get posts custom post type wp get custom post type custom query al custom post type wordpress plugin create post type making custom post type in wordpress how to get custom post type datas in wordpress create custom post type and taxonomy in wordpress making custom post types show category custom post type wordpress make custom post type in wordpress custom post type archive creating custom post type wordpress custom post types tutorial create and use custom post type wordpress adding custom post type wordpress get post custom post type category wordpress get custom post type category list in wordpress get custom post type posts wordpress get custom post type category Add Custom Field IN custom post type WordPress category template for custom post type create category for custom post type wordpress custom post tytpe page how to display custom post type categories in wordpress wordpress add support category to custom post type custom post types options custom post type page name wordpress posts of custom post type wordpress list custom post type how to display custom post type wordpress from custom post type to posts add custom post type category in wordpress what are custom post types add post type wordpress from functions.php make new post type wordpress page attributes custom post type custom post type custom fields wordpress custom post type category custom post type category access custom post type make custom post type support tags+ show custom post type adding custom fields to a custom post type add category to custom post type custom post type wordpress category wordpress custom post type fields get custom post type data in wordpress creating custom post type in wordpress' wp post type custom post type wordpress use categories wordpress custom post type use category post_type wordpress create post types wordpress oop create custome post type custom post type in wordpress 5 code wordpress post type page display custom post type category list wordpress how to add category to custom post type wordpress how to display custom post type in wordpress custom post type with wordpress custom post type field custom post typ custom post type support display wordpress custom post type categorys wordpress custom post type category widget wordpress display custom post type category name list custom post type posts wordpress how to add category in custom post type in wordpress how to display custom post type category in wordpress wordpress create category widget for custom post type wordpress add category widget for custom post type get custom post type category name in wordpress post-type e custom post type how to make custom page post type how to make custom post type page custom post type query custom post type code custom post types wptuts custom post type add category custom post type post attributes custom post type within a custom post type customk post type custom post type create in wordpress custom post type function wordpress create matching category terms to custom post type add met for custom post type create new post for a custom post type develop custom post type custom post type creation in wordpress thachpham custom post type create custom post type like post wordpress functions.php custom post type how to make a custom post type custom post in wordpress CPT in CPT wordpress make a page for a post type how to register new post type in wordpress I have added categories and tags to my custom post type, but they do not appear in the archives. create custom post type wordpress plugin costom post type what is custom post types in wordpress cpt add content create custom post type acfd create a post type wordpress how to display a custom post type in wordpress how to create a custom post type in wordpress wordpress refgister custom post type how to create custom taxonomy in wordpress with cpt wordpress filter posts by category and tag custom post type check custom post type wordpress add custom post type programmatically add wordpress post type query custom post type custom post type with category in wordpress custom post type wordpress create creating a custom post type for user i want to make form on admin side custom post type form in wordpress i want to make form on admin side custom post type in wordpress custom post type adding more custom post wordpress add data to custom post manually php wordpress custom post type structure example create post type in wordpress add custom post tyle what is the links post type in wordpress custom post type plugin add custom post type custom post type plugin code wordpress create page types for post how to load a post type on a page cpt ui to create event post with php wordpress user fill out custom post type wordpress user fill out custom post type with forms wordpress create custom post type with forms wordpress display custom post type how to use cpt ui to create a post and related post creating a post type in insert post type php wp save new post type wp create sutom post type wp add custom post type add cpt wordpress post type by code tutorial how to make custom post type in wordpress simple custom post type simple post type cusom post type wordpress post type hierarchy wordpress how to create post type add all features in custom post in wordpress is post type = custom wordpress how to create post type on wordpress by code display custom post type content get category name of custom post type wordpress wordpress how to set a post type wordpress add custom post types create a custom post using plugin developer wordpress add cpt taxonomy function starter add a meta to a custom post type use custom post type info on page custom post types on different page add custom post type wordpress wpml custom post type source type wordpress wordpress show custom post type to user add custom taxonomy to custom post type get the custom post type category wordpress create a custom post type create custom post type template wordpress wordpress post types explained wordpress custom post type single page without slug wordpress create the user at the time of custom post type creation register custom post type wordpress default post types check custom post type options custom type post wordpress custom posts type woocommerce custom taxonomy snippets How to Create Custom Post Type? wp create post type adding taxonomy to product post type in wordpress adding texonomies to product post type in wordpress how to create custom post types in wordpress add taxonomy to custom post type what is a custom post type custom shortcode show post type with custom taxonomy wpbeginner custon taxonomy custon post type how to create custom post type plugin custom post type attributes custom post type\ custom post type link wordpress dashboard create sub post types wordpress wordpress attachment post type custom post type title standar page for custom post type wordpress view custom post type wordpress for each custom post type detail page of custom post wordpress how to make detail page of custom post type in wordpress how to call custom post type in wordpress code wordpress create page for custom post wpbiginer custom taxonomy create custom post type custom post custom taxonomy wordpress custom post type create wordpress adding custom post type preferred type wordpress adding custom post type custom post types wordpress code wordpress create post types insert custom code in cpt page add code to custom post type wordpress content that can be added to custom post types wp post type options wordpress how many methods to get the all categories of the custom post type in wordpress php what are the fields that WP Generate creates for custom post type post type wordp custom post type add add custom post type in wordpress new cpt wordpress create post type wordpres custom post type how to create a custom post type for wordpress wp create custom post type form custom post type custom post types how to register custom post type in wordpress get custom post type wp+custom post type check where is custom post file is create in wordpress check where is custom post file is create in wordpress wordpress add post types wp new custom post type custom post types in wordpress custom post type as page how to create different posts types in wordpress wp create cutsom post type custom post type categories create new custom post type wordpress post types wordpress how create ustom post typpes custom post type ui insert custom post in a page wordpress custom post type wp custom post type editor tutorial wordpress add new post type function.php add custom post type how to use cpt ui post_type article wordpress add new custom post type wordpress wp-screen custom post type wordpress add custom post typ e creating a custom post type manually wordpress codex cpt wordpress costum post type wordpress cutsom post type What are the different methods you can use to create a custom post type? where i can find post type source code in wordpress wordpress admin custom post entry template plugin custome post in wordpress wordpress.org add custom post type wordpress custom psot type wordpress how to create custom post type What is a Custom Post Type in WordPress? How and why would you use a Custom Post Type? getting custom post type how to create a custom post in wordpress how to add new post_type wordpress create post type wordpress custom post type page type display custom post type in wordpress wp custom post type ui wordpress create a new post type wordpress woocommerce cpt services create and fetch custom post type wordpress hot to give public true on custom post type create page type from post type how to add a post type in wordpress how to post a post type in wordpress post type page wp custom post type what is cpt in wordpress post type wordpress custom posts wordpress post type Custom Posts types wordpress on dashboard menu custom post types wordpress code wordpress cpt link custom post types to a template wordpress load post type add custom element in posttype list page wp how to make post associated with other pos type wp custom post type php wordpress cpt custom post view wordpress wordpress custom content type how to store a single posttype in a plugin wordpress custom post type onl post type in wordpress add custom post type for woocommerce account wp add view to post type coustm post wp wp post type() page post type wordpress wordpress create custom post type custom post type code in wordpress wordpress admin custom post type wp add php in admin custom post type page wordpress create new post type custom post type wordpress example cpt wordpress wordpress add post type how to add new custom post type in wordpress what is post type in wordpress wordpress custom post type code CUSTOM CONTENT TYPE IN WORDPRESS wordpress get custom post types of other blog wordpress settings for custom post type post template post type page wordpress where i can find custom post type code in wordpress wordpress custom post type php how to create a custom post page in wordpress create a custom post type page in wordpress wordpress post types consider post types as posts wordpress wordpress custom post type post for users set text for not found posts for custom post type in wordpress function custom posts how to create custom post for text and image in wordpress create content type wordpress custom post type in wordpress code add new type wordpress how to create custom post type in wordpress create custom post type in wordpress create a custom post type in wordpress wordpress code that returns post type post and page create new post type wordpress wordpress custom post type tutorial wordpress custom post types what is a custom post type wordpress create customer post type in wordpress wordpress post type wordpress post type data custom post type in wordpress custom post type loop by taxonomy query wpbeginner custom post type loop with post_type query wpbeginner custom post type taxonomy query wpbeginner all custom post type page wordpress calling custom post type on home page custom post type wordpress WordPress add user using a custom post typ post typesx wordpress add custom post type from front wordpress wordpress custom post type functions.php wordpress custom section like post wordpress add custom post type wordpress custom post type how to get custom post type data in wordpress create custom post type wordpress create post type in wordpress code post type custom post type
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source