最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

create-guten-block in wordpress theme?

matteradmin6PV0评论

I'm working on a wordpress theme and want to replace my shortcodes with gutenberg blocks. I'm new to working with blocks but having looked into it a bit I've decided to try and use create-guten-block as that seemed like a good starting point.

The tutorial on github mentions that you should install the blocks to the plugins directory, whereas ideally I want them to be built in to my theme. Is it possible to do it this way or is it necessary to have them in a plugin?

I'm working on a wordpress theme and want to replace my shortcodes with gutenberg blocks. I'm new to working with blocks but having looked into it a bit I've decided to try and use create-guten-block as that seemed like a good starting point.

The tutorial on github mentions that you should install the blocks to the plugins directory, whereas ideally I want them to be built in to my theme. Is it possible to do it this way or is it necessary to have them in a plugin?

Share Improve this question asked Jan 9, 2019 at 19:34 Nexus6Nexus6 232 bronze badges 1
  • 1 Ideally themes only touch styling of the content and plugins modify or create content. So I guess blocks should belong to plugins. But sure, you can create blocks within a theme. In the end you just need to enqueue a script which then registers the block. – Alvaro Commented Jan 9, 2019 at 20:05
Add a comment  | 

1 Answer 1

Reset to default 1

Creator of create-guten-block here. You should be building Gutenberg blocks via companion plugins. Keep your theme for styles only :) That's the best practice for now.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far