Project Zero

Custom Post Type

WordPress currently supports a few post types out of the box:

  • Post (Post Type: post)
  • Page (Post Type: page)
  • Attachment (Post Type: attachment)
  • Revision (Post Type: revision)
  • Navigation menu (Post Type: nav_menu_item)
  • Block templates (Post Type: wp_template)
  • Template parts (Post Type: wp_template_part)

The most commonly used types would be Posts and Pages. Posts are articles with no hierarchical structure, usually published in a chronological order, while Pages are articles with a hierarchical structure.

WordPress also comes with the ability to create custom post types, building on the Page and Post post types. It is good practice to register each post type in a plugin, but you can create custom templates for your theme that support those post types. Post type archives are named archive-{post_type}.php and single posts are named single-{post_type}.php. Some plugin developers will create a default template for the post type – this has been done for Project Zero – but your custom template will take priority over the default template.

Because the custom post type is included in your template names, you do not need to do anything else to apply them to your post types.

Join the conversation

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.