How To Register Custom Post Type in WordPress

Custom Post Type gives you more power to control contents on your WordPress site. Whether you’re a developer or webmaster, you’re likely to use them a lot.

register custom post type

Before using them in your WordPress sites, you need to register custom post type. So, here in this quick tutorial you’ll know how to register custom post type in WordPress.

Register Custom Post Type in WordPress

WordPress provides register_post_type() function to register custom post type. Let’s take a look at this example :

register_post_type() function takes two parameters. These are –

  1. $post_type – Post type, this parameter is required. Default value is None.
  2. $args – This is an array of arguments. These arguments are used to register and customize custom post type.

$args can take a good amount of arguments. You can check them from here.

In our example, we have used few of them. You can pretty much understand what they do by their names. Let’s go over the arguments we have used here.

  1. labels – This is an array of labels for this custom post type.
  2. description – This is a short description about the post type.
  3. supports – This contains the feature that you want to add to your custom post type. Default value is Tittle and Editor.
  4. taxonomies – This is an array of registered taxonomies for the post type.
  5. public – This controls some other arguments. For example, if you set it to ‘true’, ‘show_ui’, ‘show_in_nav_menus’, ‘publicly_querable’ – these arguments will be set to ‘true’.
  6. menu_position – Determines where the custom post type should be added in Dashboard menu.
  7. menu_icon – This is the icon that will added alongside the custom post type in menu.
  8. has_archive – Enables archives for post type.
  9. capability_type – Builds the read, edit, and delete capabilities. Default values is ‘post’.
  10. rewrite – This takes boolean or array value. If you set to ‘false’, it’ll prevent rewrites. Or you can assign an array and use ‘slug’ to customize the permalink structure.

So, these are some of the arguments you can use. Don’t forget to check other arguments from the codex. Finally, you have to hook the function to ‘init’ action.

Over to You

Now you know how to register custom post type in WordPress. If you have any questions or confusions, don’t forget to ask them through comments.

Share this with others if you found this helpful.

Click Here to Leave a Comment Below


Wow That is an amazing article.
Thank you Imtiaz Rayhan for sharing

Yasar Ali

Very Awesome Sharing Dear Bro.
Keep up the work.

Sadhan Pal

Hi Imtiaz!

Thanks for kindful information. Will you tell me please any other PHP compiler name without Adobe DreamWeaver?

Sadhan Pal

    Imtiaz Rayhan

    Hi Sadhan,

    I am sorry I don’t have good ideas about that. You can Google to find out something.


Joseph Chikeleze

Hello bro, thanks for this tutorial on how to add new custom post type on WordPress.

Thanks and do have a nice day!

Leave a Reply: