What is a WordPress Custom Post Type?
WordPress custom post types let you add your own data types to the WordPress admin. Out-of-the-box, WordPress comes with pages and posts. If you want to display other types, such as products, testimonials, projects and anything else, the best way is to setup custom post types.
This way, different types of content are organized under different menus. You can also control user-access for different types, allowing better management of your site.
Creating a custom post type is easy with Types. All you have to do is add the name and settings, and your new custom post type is ready.
- Basic setup
- Advanced setup
- Parent / child relationships between different custom post types
Let’s take a look at how you can create a custom post type for a property letting website.
1. Basic Setup – Name Your Custom Post Type
Go to Types > Custom Types and Taxonomies and click “Add New Custom Post Type“.
At the top you should add your name and description, along with your slug and a description. The ‘slug’ field is what identifies the custom type inside WordPress. It may only contain English letters, digits and underscores. The Plural and Singular names may contain any characters.
For a Property website we can use the following:
- Plural name – Properties
- Singular name – Property
- Slug – property
- Description – Properties that we have available to rent
When you are happy with your settings click save.
Your new custom post type will now be available on the WordPress admin menu.
2. Advanced Custom Post Types Settings
Besides the basic setup (name, description and slug), Types gives you access to advanced setup. Although not always required, advanced setup will let you fine-tune everything about your data types.
2.1 Custom Post Type Visibility
The Visibility option lets you determine whether your custom post type will appear in the WordPress Admin or not. As we want users such as authors and editors to be able to add property to the website we will make it visible.
If you’re creating the custom post types programatically (with code), you probably don’t want them appearing on the menu. However, most custom types you’ll be creating with Types should usually be editable.
You can also change the menu positioning (i.e. where your custom post type will appear on the Admin menu – see the section on menu_position in the Codex for more information) and the icon.
2.2 Attach Taxonomy to Custom Post Types
Taxonomies are used to categorize your post types. The most common WordPress taxonomies are categories and tags.
If you have created a custom taxonomies for your custom post type you can attach them here. If you haven’t created taxonomy yet, learn more about creating custom taxonomy.
2.3 Set Labels for Custom Content Types
Labels are the pieces of text that are attached to different areas of the admin screen, for example “Add New Property” or “No Property Found”.
While the defaults often suffice, it can be useful to be able to tweak these labels to further customize your admin screen.
2.4 Choose Which Sections to Display
Types lets you choose which of the default WordPress sections you would like to display on the Add New/Edit Property page. These are:
- Title – the title of the post type (selected by default)
- Editor – the input text area (selected by default)
- Comments – give author ability to turn comments on or off
- Trackbacks – give author ability to turn trackbacks and pingbacks on or off
- Author – add a dropdown menu for changing the post author
- Excerpt – add a customized excerpt
- Thumbnail – give the author the ability to upload a featured image
- Custom-fields – add the custom fields input area
- page-attributes – add the page attribute to change the display order
- post-formats – add post formats (such as aside, link, video)
2.5 Even More Advanced Custom Post Types Settings
Advanced settings let you further tweak your custom post type. Normally the defaults should be fine but in case you want to fine-tune everything about your custom post types, here is what these options mean:
- Rewrite – rewrite post types permalinks. You can use the normal WordPress URL logic (which you will have set up in Settings > Permalinks) or you can use a custom URL format. The default for this is “true” and it will use the slug you defined earlier.
- Allow permalinks to be prepended with front base – if you are prepending your permalinks with a phrase such as /blog/ selecting this will also prepend your new custom post type with this phrase e.g. /blog/property/
- Feeds – choose whether to publish a feed for this post type. It will default to the has_archive setting (see below) but this give you ability to turn off feeds while keeping an archive page.
- Pages – is the custom post type a dynamic (post) or static (page) piece of content
- has_archive – determine whether the post type has an archive page or not.
- show_in_menu – determine whether you want your post type to show in the admin menu or not.
- show_ui – generates the user interface for the post type. If you don’t want a UI you should uncheck this.
- publicly_queryable – determine whether post type queries can be performed from the front end.
- exclude_from_search – check this if you want to exclude your post type from search results.
- hierarchical – lets parents be specified.
- can_export – allow this post type to be exported.
- show_in_nav_menus – determine whether this post type is available for inclusion in navigation menus
- query_var – allow or prevent queries
- Permalink epmask – add an endpoint to your custom post type. See here for more info.
3. Parent / Child Relationship
Types plugin also lets you connect different custom post types using parent / child relationships. For example, if you’re creating custom types for artists and shows, you can make the ‘show’ children of ‘artists’. Scroll down to the bottom of the post type editor. You’ll see a small section called Post Relationship.
When you enable parent / child relationships between custom post types, you’ll be able to:
- Choose the parent for children
- List all the children of a parent
- Bulk-edit child items from parent editor
Want to Learn More?
- Learn how to use custom fields
- Learn how to use custom taxonomies
- Create View Templates to edit the design of your custom post types
- Display your content using Views
Types is a free plugin for managing custom post types, taxonomy and custom fields.Download Types