Saturday, July 16, 2022
HomeWordPress DevelopmentHow do I assign a block template (.html) to a customized put...

How do I assign a block template (.html) to a customized put up kind?


I am utilizing WordPress 6.0 and I’ve created a toddler theme from TwentyTwentyTwo. I’ve created a customized put up kind utilizing code like this:

register_post_type('foobar', [
   'public' => true,
   'show_in_rest' => true, // enable block editor
   // etc
]);

In my baby theme, I’ve created the listing templates, and inside it, a file named foobar.html. I’ve copied the contents of single.html from twentytwentytwo/templates/ to this folder and renamed it to foobar.html to make it match the customized put up kind.

If I open the location editor, and click on “Templates”, I see these templates listed:

  • Single Publish
  • Web page
  • foobar
  • Dwelling
  • Search
  • and so forth…

Nevertheless, once I create a brand new put up of the customized put up kind foobar utilizing the WordPress admin interface, the default template is “Default template”, and never “foobar”. How do I modify the default block template for a customized block kind?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments