As of version 1.6, USP Pro supports unlimited Custom Post Types (CPTs). Here is a quick tutorial explaining how to set it up.

Video Tutorial

Written Tutorial

Step 1: Theme Support

First make sure that your theme supports whichever Custom Post Type (CPT) that you would like to use. Here is an example of the typical code that is used to support a Custom Post Type (added to functions.php):

// example custom post type
function codex_book_init() {
	$labels = array(
		'name'               => _x('Books', 'post type general name', 'your-plugin-textdomain'),
		'singular_name'      => _x('Book', 'post type singular name', 'your-plugin-textdomain'),
		'menu_name'          => _x('Books', 'admin menu', 'your-plugin-textdomain'),
		'name_admin_bar'     => _x('Book', 'add new on admin bar', 'your-plugin-textdomain'),
		'add_new'            => _x('Add New', 'book', 'your-plugin-textdomain'),
		'add_new_item'       => __('Add New Book', 'your-plugin-textdomain'),
		'new_item'           => __('New Book', 'your-plugin-textdomain'),
		'edit_item'          => __('Edit Book', 'your-plugin-textdomain'),
		'view_item'          => __('View Book', 'your-plugin-textdomain'),
		'all_items'          => __('All Books', 'your-plugin-textdomain'),
		'search_items'       => __('Search Books', 'your-plugin-textdomain'),
		'parent_item_colon'  => __('Parent Books:', 'your-plugin-textdomain'),
		'not_found'          => __('No books found.', 'your-plugin-textdomain'),
		'not_found_in_trash' => __('No books found in Trash.', 'your-plugin-textdomain'),
	);
	$args = array(
		'labels'             => $labels,
		'taxonomies'         => array('category'),
		'public'             => true,
		'publicly_queryable' => true,
		'show_ui'            => true,
		'show_in_menu'       => true,
		'query_var'          => true,
		'rewrite'            => array('slug' => 'book'),
		'capability_type'    => 'post',
		'has_archive'        => true,
		'hierarchical'       => false,
		'menu_position'      => null,
		'supports'           => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields')
	);
	register_post_type('book', $args);
}
add_action('init', 'codex_book_init');

This code is directly from the WordPress documentation for Custom Post Types, so feel free to learn more about it there, or use a free online Custom Post Type Generator to roll your own. Alternately you can use a plugin or theme to implement CPT support.

Important: make sure to enable custom fields by including custom-fields in the supports parameter.
Update: make sure to enable categories for any Custom Post Types by including array('category') in the taxonomies parameter.

Once your site has a Custom Post Type implemented and ready to use, follow the next step to use it for posts submitted from any USP Form.

Step 2: Form field

So once your Custom Post Types are all set up and ready to go, add the following hidden field to any USP Form:

<input name="usp-custom-type" value="book" type="hidden">

Then change book to yourCustomPostType to use your Custom Post Type for that form. This enables you to set up multiple forms for multiple Custom Post Types, while using the default post type (as specified via USP SettingsAdvancedSubmitted Post Type) for any forms that don’t include the hidden field.

Notes

You can also use the hidden-field method to create forms for any of the following built-in post types (i.e., any of the CPTs available under AdvancedSubmitted Post Type). For example, your form can include any one of these hidden fields to specify the CPT:

<input name="usp-custom-type" value="post" type="hidden">
<input name="usp-custom-type" value="page" type="hidden">
<input name="usp-custom-type" value="usp_post" type="hidden">

..or any of your own, such as:

<input name="usp-custom-type" value="book" type="hidden">

So for example, you could set the plugin option for AdvancedSubmitted Post Type to “USP Posts”. That way, the built-in Custom Post Type USP Post will serve as the default. Then you can use a hidden field on any form to override the default and submit content as regular WP Posts, WP Pages, or any other supported CPT. It’s good times ;)

How to use the example templates

In order to display any Custom Post Type (CPT), your theme must provide the proper templates. To help with this, USP Pro provides a couple of example CPT templates that may be added to your theme. They are located in the plugin’s /templates/ directory:

  • /templates/single-usp_post.php
  • /templates/archive-usp_post.php

So you can copy these templates and paste them into the root directory of your current theme (or child theme). Specifically, these CPT templates are for displaying the built-in “USP Post” CPT. They are very minimal and meant only to help get you started with displaying CPTs on the frontend.

Note: If you still do not see the USP Post CPT on the frontend after adding these templates, try visiting your site’s “Permalink” settings (in the WP Admin Area), and clicking “Save Changes” (without making any actual changes); that is a recommended fix for an old well-known WordPress bug.

Related