When you call register_post_type()
to register your custom post type, one of the args is called template
which is described as follows:
Array of blocks to use as the default initial state for an editor session. Each item should be an array containing block name and optional attributes.
So whereever you have the register_post_type()
, you could do:
register_post_type(
'document',
array(
…,
'template' => array(
array(
'core/pattern',
array(
'slug' => 'theme-name/document-block-pattern',
),
),
),
)
);
Or if you want to add the template
in some package that is decoupled from the code that calls register_post_type()
, you can use the register_{$post_type}_post_type_args
hook:
function function_name( $args ) {
$args['template'] = array(
array(
'core/pattern',
array(
'slug' => 'theme-name/document-block-pattern',
),
),
);
return $args;
}
add_filter( 'register_document_post_type_args', 'function_name' );
Related Posts:
- How to enable REST API on custom post type without Gutenberg?
- How to Customize the Admin Sidebar Menu in WordPress Multisite Network by changing the backend code of the wp-admin code files?
- How to get the post title inside a custom block in a loop? block.js
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- bp-custom.php is not working on a WordPress multisite environment. how to fix it?
- WordPress Multisite login_redirect to primary blog and specific page based on role
- Additional file upload in Gutenberg page options/featured image
- Add Block Before Entry Title Using PHP
- How to populate a Gutenberg select field SelectControl with option value from PHP array
- Gutenberg Blocks and get_option() for styling
- How can I update WordPress plugins or WordPress itself in all server?
- How to extend SelectControl with data from my theme
- WP Admin Bar – Get current theme name as custom menu title
- Display a query with multiple post types and same relationship on a single page
- WPMU schedule doesn’t execute actions
- WP multisite network plugin fails to see classes loaded with spl autoload
- Host does not allow remote connection, so how do I transfer data to my WordPress site?
- Trying to post information from a remote database to wordpress page
- Custom PHP-coding in MU installs
- .htaccess on multisite and roots theme?
- Force string into signup form
- I need a button to appear when not loged in and another when logged in, I need help fixing code PLEASE!
- WPMU – How to echo only one URL
- Losing Session ID and sessionStorage when navigating to other domains on Multisite
- Display all categories (with link) of custom post type – WordPress
- Gutenberg – render_callback does not pass ToggleControl value on frontend
- How can I get values from a custom post type depending on where I click on my SVG map?
- Add default block css when the block has been added with php?
- Displaying custom meta box value in a custom post page
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin
- WordPress different custom tag being displayed in on tag list
- How to add different menu items on different menus?
- Can I associate a custom post type with another custom post type?
- Get category name of current post (CPT UI)
- How to sort custom sortable column by custom table value
- I want to show image from custom field image on my custom page template
- How to disable page create for custom post type, but allow a page with the post types slug to be created?
- Replace block content with an array
- How to use multiple custom post types to archive as front page?
- Include a static block inside of a dynamic block
- How to make multiple custom taxonomies sit under custom post type slug?
- Limit a search box by CPT + taxonomies, in only one page
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- WordPress taxonomy and terms question
- Load style and script for custom post type metabox
- Custom CPT – Programmatically create categories to assign CPT when a new one is created
- Internal server error when enabling Multisite in WordPress
- Why do I get a 404 error on my custom post type archive pagination?
- How do I exclude the current post from the upcoming post query
- Save_Post change Custom Post Type Post title to post id number
- Custom Filtering date with newsletter
- Ajax infinite scroll random order shows duplicate posts on custom post type
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- How to create a build for quickly deploying a server with WP?
- Manipulating the allowed inner blocks of a core-gutenberg-block?
- Custom post type removing /page/2/ from URL when trying to access it
- Same Custom Post Type Slug and Custom Taxonomy Slug, with hierarchial unique permalink structure
- fetch from an external api call and display results in page
- WordPress CPT & Custom Taxonomy with the SAME Permalink Structure
- Adding features to Gutenberg without theme.json
- Registering a custom block style
- Remove slug and custom post type name from URL
- NGINX rewrite rules for WordPress Subdirectory Multisite to support deep URL
- Hot to show custom post type taxonomies on archive page
- Integrate a Custom Post Type with Learndash Plugin
- child category under correct parent
- Single wordpress multi website down need help factoring what it is
- Get column block count using PHP method render_block
- Remove slug of multiple custom post types with and without hierarchical
- do_blocks not working with a custom block
- Quiz page template, checked attribute missing when option selected
- ACF block gutenberg aligncenter don’t work
- Change WordPress Multisite Domain to subfolder
- Redirect WordPress page to the latest created post by the logged in author/user
- Execute a PHP Function when a Block is used and access it’s attributes
- Is it possible to go to the next post in the same category?
- Send summary email from a form with wp_mail
- create custom post type and populate custom fields using php
- Want to add custom post type for facebook feed
- Enabling pretty permalinks with Docker, Multisite WordPress and Caddy
- How to edit templates created in the block editor in code / template files not updating
- Running WP-Cron on Multisite networks the right way?
- Programmatically convert single classic block to individual blocks via PHP
- Add custom data attribute to every core Gutenberg Blocks
- Embed dynamic media query in a Gutenberg block
- Get generated block styles programmatically
- Custom gutenberg block refuses to load viewScript and I don’t know why
- Custom Post Types in WordPress Dashboard List Rows But Data is Blank
- Options of select field in a custom divi module ignore sorting
- How to add query string at the end of sitemap Yoast SEO
- When a foreach loop is used multiple times in blocks, is there a way to ensure a variable always has a unique value?
- Custom theme on multisite has issues with standard loop output
- Prevent render in editor via PHP
- How to Bulk Update CPT Taxonomy Values Using CSV Lookup Table
- How to display only the first 2 words of a post title
- How to get the content of a dynamic block in PHP
- Post returns 404 after changing the permalink using post_type_link
- REST API request between domain and subdomain
- Cannot access the other pages after successfully editing post type