MB Custom Post Type

Edit this page on Github

Overview

The MB Custom Post Type extension is a powerful tool that helps you manage your custom post types and custom taxonomies via a user-friendly interface. It’s very helpful when you want to create or edit a custom post type / custom taxonomy without touching code.

screenshot

For more information, please see the extension page.

Installation

Before installing the extension, you need to install Meta Box plugin first.

  1. Go to Plugins → Add New and search for Meta Box
  2. Click Install Now button to install the plugin
  3. After installing, click Activate Plugin to activate the plugin

The extension is just a WordPress plugin, you can install it like a normal WordPress plugin.

  1. Go to Plugins, click Add new, then click Upload plugin.
  2. Choose the .zip file you downloaded and click Install now
  3. After finishing upload, click Activate to finish.

Usage

After installing and activating the plugin, you’ll see new menu items Meta Box → Post Types and Meta Box → Taxonomies. Clicking on each menu will go to the admin page where you can create/edit custom post types and custom taxonomies.

Here is the video tutorial on using the plugin to create a custom post type:

Notes

Custom capabilities for custom post types

When creating custom post types, you have 3 options to set capabilities: copy from “post”, copy from “page” or create custom capabilities. While copying from “post” or “page” is clear (the plugin simply applies the same capabilities from post or page for this custom post type), creating custom capabilities might be confusing.

When you select “custom” for capabilities, the plugin does the following (assumming we have a post type book):

  • Set 'capability_type' => array( 'book', 'books' ),, and
  • Set 'map_meta_cap' => true

These 2 steps will create the following capabilities for the post types:

[edit_post]              => 'edit_book'
[read_post]              => 'read_book'
[delete_post]            => 'delete_book'

// Primitive capabilities used outside of map_meta_cap():

[edit_posts]             => 'edit_books'
[edit_others_posts]      => 'edit_others_books'
[publish_posts]          => 'publish_books'
[read_private_posts]     => 'read_private_books'

// Primitive capabilities used within map_meta_cap():

[read]                   => 'read',
[delete_posts]           => 'delete_books'
[delete_private_posts]   => 'delete_private_books'
[delete_published_posts] => 'delete_published_books'
[delete_others_posts]    => 'delete_others_books'
[edit_private_posts]     => 'edit_private_books'
[edit_published_posts]   => 'edit_published_books'
[create_posts]           => 'edit_books'

And thanks to map_meta_cap, standard admin role is able to edit the posts types.

Block templates with MB Blocks

Sometimes you want to load default blocks created by MB Blocks when creating a new post. Block templates allow to specify a default initial state for an editor session. Use the argument template when registering the post type:

'template' => [ ['meta-box/{$block_id}'] ]

Reserved terms

There is a complete set of reserved keywords, or terms, in WordPress that should not be used in certain circumstances as they may conflict with core functionality. See more in the documentation.

Force migrate

Since version 2.0.0, we’ve used the React JS when creating post types and taxonomies. If you update this extension from the older version 1.9.5 and face some errors like encoding characters or post types, taxonomies disappeared, please add the param mbcpt-force=1 to the URL and run it to force migrate post types and taxonomies to the new version. Example: http://domain.com/wp-admin/?mbcpt-force=1

Edit this page on Github