Add Custom Post Types to Zoninator

Zoninator is an simple plugin for being able to curate content on a WordPress website. While I personally feel that more can be done in WordPress when it comes to curation of content, Zoninator ticks most boxes of a simple to use and easy to implement curation solution.

By default, Zoninator only lets you select posts when selecting content for a specific zone that has been created. That’s all good and well, but what about when you want to select a piece of content that is filed under a Custom Post Type?

Turn’s out, you need to enable support for zoninator when registering the custom post type. To do that, simply add zoninator_zones┬áto the supports argument when registering the Custom Post Type

Add Zoninator support when registering a Custom Post Type

Here is an example snippet of a Custom Post Type that is registered and includes support for Zoninator.

add_action( 'init', 'codex_book_init' );

 * Register a book post type.
 * @link
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,
                'description'        => __( 'Description.', 'your-plugin-textdomain' ),
		'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', 'zoninator_zones' )

	register_post_type( 'book', $args );

Again, the specific piece to take note of is the supports argument. There is another method to enable support for Custom Post Types. If you did not register the Custom Post Type yourself or you don’t have control over it in your code, you can use the add_post_type_support function.

Alternative Zoninator add post type support method

Simply call the following function (just make sure it’s called after the post type is registered). It’s also a good idea to use an action to fire off the function.

function mg_register_post_type_support() {
	// Zoninator on pages.
	add_post_type_support( 'page', 'zoninator_zones' );
add_action( 'after_setup_theme', 'mg_register_post_type_support' );

And there you have it. Two simple ways of adding Custom Post Type support for Zoninator.

Leave a comment

Your email address will not be published. Required fields are marked *

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