B2B Marketing Insights by Ironpaper

Developing a Wordpress custom post type

Written by Ironpaper | February 05, 2014

Custom post types allow developers to extend the Wordpress platform to allow for different types of content to plugins and themes. Simply stated, a custom post type is a special type of content defined by a web developer for a website. Web developers can define both the properties of that content and the design of the content for frontend users. Often times people are confused about the term "post type." Custom posts do not just imply blog posts, Wordpress comes with a number of default post types natively.

Default Wordpress post types

  • Posts
  • Pages
  • Attachments
  • Revisions
  • Navigation menu items

Creating a custom post type in Wordpress

The Wordpress platform makes it easy to program new post (content) types and add them to a website. You will need to define the new post type inside the functions.php file inside your theme.

add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'acme_members',
array(
'labels' => array(
'name' => __( 'Members' ),
'singular_name' => __( 'Member' )
),
'public' => true,
'has_archive' => true,
)
);
}

That's it. This statement creates a new post type called Member, which can be used to create a member database. This is the start of using Wordpress to develop a membership website. Certainly a lot more options can be added to our post type called "Member." The options can include setting Admin labels as well as adding additional fields. It is a good idea to prefix any post type created with a unique naming convention to prevent conflicts with other plugins.

Viewing the new post-type as an archive (list) page:

archive-{posttype}.php

This article is meant to be a quick reference for Wordpress web developers and not an extensive guide.