0

I need to wrap a series of Gutenberg blocks into a parent container that can get its own CSS class. I've tried to use a table block and set it to '1 column'. But that still creates a 50% width 'column' block for any nested block added inside. How can that be done without using an HTML block and actually wrinting markup code?

Any help will be much appreciated. Bunjip

  • It sounds like you need to create your own "parent" block that can accept whichever "child" blocks you need. Your parent block can set whatever CSS class you are needing - or dynamically allow the user to set its CSS class, whichever you like. Have you looked into Inner Blocks? – WebElaine Apr 15 at 16:12
  • Thnx, @WebElaine. That's kinda what I'm looking for. A block that wraps around other blocks. This could be done within an HTML block, but it that's not what I'm looking for. I've read about Inner Blocks here and tried 'columns block' as I wrote in my question. However, I still have no clue how to add a wrapper element around other blocks. – Bunjip Apr 15 at 18:03
  • I don't think there's any way to add a wrapper element around multiple blocks unless you register your own block type and allow Inner Blocks. Then you can have your own block with whatever classes you need, and it can contain whatever regular Blocks inside it that you need it to. If you just needed a class around a single existing block there are filters that would handle the job, but they only work on individual blocks. – WebElaine Apr 15 at 20:40
  • Just found plugin called Ultimate Addons for Gutenberg which contains a block named 'Section'. This is quite what I'm looking for. Think this is of such a basic need if using blocks as a page building concept, that it could well be adopted by Gutenberg natively... – Bunjip Apr 17 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.