Content in WordPress is easiest to manage when divided down into separate post types. A post is a piece of content in WP, and a post type is a way of categorising the posts. The advantage of defining content in this way is that built in WordPress conventions can be taken advantage of. These include many functions that collect and iterate through posts by type, and templates that are used on the front end when users view collections of or single posts. For more information on posts, view this article on custom posts.

To add custom posts to a site, customise and use the following code within functions.php, or anywhere in your theme that WordPress hooks can be accessed.

 

$labels = array()

This array of strings determines the name of the custom post type and the admin menus relating to it.

 

$args = array()

These are the possible arguments that change details about the custom post type that is being created.

 

register_post_type( ‘client’, $args )

This is the WordPress function that creates the post type. The first parameter is the name of the post type as it will be referred to in all other functions, and the second parameter is the list of arguments that alter the details of the post type.

 

add_action( ‘init’, ‘create_clients_post_type’, 12 )

The WordPress hook runs the function ‘create_client_post_type’ on init, with a priority of 12.