Custom Post Types are post types that you can create in WordPress. By default WordPress has 5 post types:

  • Post (Post Type: ‘post’)
  • Page (Post Type: ‘page’)
  • Attachment (Post Type: ‘attachment’)
  • Revision (Post Type: ‘revision’)
  • Navigation menu (Post Type: ‘nav_menu_item’)

You may add you own post types as well. For example, you may want to add a custom post type for Videos and then display those videos on a template page in a carousel. The best way to set up a Custom Post Type is by creating a plugin, but you can also place these examples into your theme’s functions.php file.

You can register your new Custom Post Type with the register_post_type() function:

The $args array stores some important settings regarding what features your new Custom Post Type will support. You can view the full range of options on the WordPress Codex page for register_post_type.

The most important settings are the ‘supports’ and the ‘menu_position’ values.

The ‘menu_position’ value determines where in the WordPress admin’s menu the link to your Custom Post Type will appear. Set this to 5 to show the menu item below the ‘Posts’ link.

The ‘supports’ array determines what default WordPress features your Custom Post Type will support. For instance, removing the ‘editor’ value from this array would remove the WYSIWYG editor, or removing the ‘thumbnail’ value would remove the Featured Image section.

Next you can set up custom taxonomies for your Custom Post Type:

Next you can set up a custom field for your Videos to store the URL using the add_meta_box() function:

Now add an action containing the update_post_meta() function to save your Video URLs entered into the post meta box you created above:

You can add the Category column to the list of posts you see when you click the Videos menu item in the WordPress admin:

Now that you’ve set up your Custom Post Type for Videos, you can change the default placeholder text of the Video title as well, by adding an enter_title_here filter:

Be sure to leave the default value in the else section of the if statement. This is the value that will be used for your posts. You can add any other Custom Post Types you set up here as well to set their default placeholder text for the title field.

To filter by the Category column in the list of posts, add a parse_query filter:

As you can see, Custom Post Types are a very powerful tool and a great and user-friendly way for your users to manage different types of content in WordPress.