custom post

How to create custom post type in wordpress ?

Custom post type? Confused ?

Cheers! Don’t be getting confused. Please read the following paragraph once. ?What is custom post type then ?
Custom post type is simply WordPress content like the page, post etc. WordPress simply have following post types.

  1. Post
  2. Page
  3. Attachment
  4. Revision
  5. Nav Menu

So, post type is simple content and it’s like a content category but not actually category. It’s like a group of content.

How can I register my own custom post type?

Dude! It’s very simple, very means it’s simple ? But the main thing is you have to know what is simple PHP functions and how WordPress PHP file structure is? and some basic WordPress hooks. That’s all for custom post type.

ohh ! Still confusing ? Then let’s write this code in your theme directory’s functions.php.  ?

// Our custom post type function
function create_posttype() {

register_post_type( 'movies',
// Custom post type Options
array(
'labels' => array(
'name' => __( 'Movies' ),
'singular_name' => __( 'Movie' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'movies'),
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );

That’s all for now ? Now look around on backend, you will find your custom post type.

Looks like it’s very interesting?
Want to know more about custom post type?
Then please follow the following official link from WordPress.

https://codex.wordpress.org/Post_Types

What Is A WordPress Theme ?

Ravi K Ranjan
Hi, i am Ravi K Ranjan. MD & CEO of Magatron Animation Pvt. Ltd. Company Started From 6 January 2014. My Business Skill is Graphics Designing, Web Designing, Domain and Hosting Services Provider, Online/Offline eBook Making, Online Advertising.
https://ravikranjan.com/about-us/