Plugin Planet

Premium WordPress Plugins

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

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 Codex page on Custom Post Types, so feel free to learn more about it there, or use a Custom Post Type Generator to roll your own. Alternately you can use a plugin 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.

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 Settings > Advanced > Submitted 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 Advanced > Submitted 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 Advanced > Submitted 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 ;)