Custom Post Type Builder
3 min read Updated
The Custom Post Type Builder adds your own post types, such as Projects or Team Members, without code. You build one Page Builder layout for each post type. Each new post of that type starts with that layout, and a change to the layout can update all the posts.
Requirements
- SiteOrigin Premium
- Page Builder by SiteOrigin
- SiteOrigin Widgets Bundle. The post type settings form needs it.
Go to SiteOriginPremium Addons and activate Custom Post Type Builder. While the addon is active, its card has a Manage Post Types button. It opens the Post Types screen.
How It Works
Go to ToolsAll Post Types. Only users who can manage the site options, such as administrators, see this screen. Each entry on it is one post type. An entry registers its post type when you publish it.
The Page Builder layout of the entry is the template for all posts of that type. The Editable layout setting controls how the template and the posts connect:
- Off (default): Posts always use the rows and styles of the template. Editors can change the content of the widgets, but they can’t add, move or delete rows and widgets. A widget follows the template until an editor changes it in a post.
- On: The template is only the starting layout. Editors can change the layout of each post, and later template changes don’t reach existing posts.
You can also mark a widget in the template as Read Only. A Read Only widget has the same content in every post, and you can only change it in the template. Use it for content that repeats, such as a call to action. At the moment, Read Only works fully only when Editable layout is off.
Some other points:
- The Post Types screen and all post types you build with the addon always use the Classic Editor, with Page Builder.
- Page Builder is always on for these post types. They don’t show in the Post Types setting at SettingsPage Builder.
- If you deactivate the addon, WordPress no longer registers the post types. Their posts stay in the database, and they come back when you activate the addon again.
Usage
The example is a Projects section for Northfield Studio, a small web design studio in Leeds. Each client project gets its own page with the same layout: a large image, a project summary, and a “Start your project” call to action at the bottom. Visitors can also browse projects by type, such as Website, Branding or E-commerce.
These pages show how to build it:
- Adding a New Post Type: create the Projects post type, build its layout and choose its settings.
- Custom Taxonomies: add a Project Types taxonomy to group the projects.
- Adding New Posts: add each project with the layout from step 1.
- Displaying Content: show the projects on other pages with widgets.
- Page Settings: set the theme’s page settings for all projects at once.
Advanced Customizations
Add PHP snippets with a plugin such as Code Snippets, or in a child theme’s functions.php file.
Change the arguments of a post type
The siteorigin_premium_cptb_post_type_register filter changes the arguments the addon passes to the WordPress register_post_type() function. It receives the arguments and the post type slug. This example changes the URL base of the projects post type from /projects/ to /work/:
add_filter( 'siteorigin_premium_cptb_post_type_register', function( $args, $slug ) {
if ( $slug === 'projects' ) {
$args['rewrite'] = array( 'slug' => 'work' );
}
return $args;
}, 10, 2 );After you add or change this snippet, go to SettingsPermalinks and click Save Changes to update the URLs.