WordPress CMS Installation Guide

How to create custom post type in wordpress ?

Posted on
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

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


  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
  •  
    1
    Share
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  

One comment How to create custom post type in wordpress ?

  1. What is this capacity of this script?It’s advertised as a Giant Social Network Platform.Can it handle over 100 000 users and does it require special server or notCY. it can be used as hosted solution?I will work on a project for a social network similar to baby! or notCY. Would it be possible wiith WP?

Leave a Reply

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