admin管理员组

文章数量:1391974

custom post template design with dropdown option Hi problem is after I design a post with GUTENBERG how can I save this as a post template to reuse for future post ?

custom post template design with dropdown option Hi problem is after I design a post with GUTENBERG how can I save this as a post template to reuse for future post ?

Share Improve this question asked Feb 18, 2020 at 19:28 learning wordpresslearning wordpress 1
Add a comment  | 

1 Answer 1

Reset to default 0

To make a template that appears in the specific dropdown menu you're referencing, you need to create a file in the theme (or child theme). Let's say you're creating "tpl-events.php". Inside the file you'll add comments at the top:

<?php
/*
* Template Name: Events
*/
?>

The template will then appear in any post type that allows custom templates. If you'd like to specifically allow the template to be used in a CPT, you can add another comment:

<?php
/*
* Template Name: Events
* Template Post Type: page, event
*/
?>

If you're instead wanting to create a template of blocks to use on a page, you can either:

Create a reusable block - group all of your blocks in a single Group block and use the three-dot menu to select the Reusable Blocks option.

or

Set up a CPT template - if you'd like to have empty blocks added whenever you create a new post of a certain type, you can set this up either where the post type is registered or else add a filter.

本文标签: custom post template design with dropdown option