WordPress CMS Installation Guide

How to create custom post type in wordpress ?

Posted on

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

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.

40 comments How to create custom post type in wordpress ?

  1. Hey exceptional blog! Does running a blog like this take a large amount of work?
    I’ve no expertise in coding but I was hoping to start my own blog soon. Anyway, should
    you have any suggestions or techniques for new blog owners please share.
    I know this is off topic however I simply wanted to ask.
    Thanks a lot!

  2. Wow, fantastic weblog layout! How long have you been blogging for?
    you make blogging glance easy. The total glance of your site is
    magnificent, let alone the content material!

  3. If you are going for most excellent contents like I do, simply pay a quick visit this web page every day since it provides quality contents, thanks

  4. Everything is very open with a very clear clarification of the issues.
    It was really informative. Your site is very useful. Thanks for sharing!

  5. Simply desire to say your article is as surprising.
    The clarity on your publish is just great and that i could suppose you’re
    an expert on this subject. Fine with your permission allow me to
    grab your feed to stay updated with coming near near post.
    Thank you one million and please continue the enjoyable work.

  6. It is really a nicee and helpful piece of information. I’m satisfied that you simply shared this useful information with us.
    Please keep us informed like this. Thank yyou for sharing.

  7. Great post. I used to be checking constantly this blog and I
    am inspired! Very helpful information specifically the
    final part 🙂 I deal with such info much.
    I used to be looking for this certain information for a very lengthy
    time. Thanks and best of luck.

  8. I have to thank you for the efforts you’ve put in penning this website.
    I really hope to check out the same high-grade
    content by you in the future as well. In fact, your creative writing abilities has encouraged me to get my own, personal site
    now 😉

  9. We’re a group of volunteers and starting a brand new scheme in our community.
    Your website offered us with helpful information to work on. You’ve done an impressive activity and our
    whole group can be grateful to you.

  10. I have been browsing online more than 3 hours today,
    yet I never found any interesting article like yours. It is pretty worth enough for me.

    In my opinion, if all web owners and bloggers made good content as
    you did, the web will be a lot more useful than ever before.

  11. Nice post. I was checking constantly this weblog and I’m inspired!
    Very useful info specially the last section 🙂 I deal with such information a lot.
    I used to be looking for this particular info for a very lengthy time.
    Thanks and best of luck.

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.