ThemeCentury Black Friday Offer
WordPress CMS Installation Guide

How to create custom post type in wordpress ?

Posted on
Web Hosting

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

Web Hosting

themeegg

ThemeEgg is beautiful, modern, clean, responsive, SEO friendly, premium and free WordPress theme and plugin store. We have highly customizable and good looking WordPress themes and plugins to create a beautiful website. We can also provide themes and plugins customization support.

3 comments How to create custom post type in wordpress ?

  1. When someone writes an article he/she keeps the thought of a user in his/her mind that how a user can understand it.

    Therefore that’s why this piece of writing is outstdanding.
    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.