- This topic has 9 replies, 4 voices, and was last updated 9 months, 1 week ago by David.
August 5, 2019 at 4:21 am #975975Michael
My scenario: I created a reusable Gutenberg block (a separator with some svg content).
Now I want to add that reusable block with a hook so the separator also displays on archive and single post pages.
But how can I achieve that with the Elements > Hook Settings?
What I don´t get is how I can “print” in or add the reusable block via function in a clean way.
Do you have a hint in the right direction?
MikeAugust 5, 2019 at 5:31 am #976014DavidStaffCustomer Support
as the Re-usable block is a post type then you can try this:
<?php // get reusable gutenberg block: $get_block = get_post( XXXX ); echo apply_filters( 'the_content', $get_block->post_content ); ?>
XXXXwith the ID of the re-usable block.
However, this will not load dynamic CSS styles – fine if its a core block but you may see a loss of styling if 3rd party blocks are used.August 5, 2019 at 5:57 am #976034Michael
awesome. That worked.
Thank you very much!
MikeAugust 5, 2019 at 6:06 am #976041DavidStaffCustomer SupportMarch 25, 2020 at 6:57 am #1209484George
Sorry for reopening the thread. I have tried the solution using GenerateBlocks that have been converted to reusable blocks but the whole layout and styling have disappeared. I guess it’s what you mentioned, David. Is there going to be a solution to this for GB?March 25, 2020 at 7:01 am #1209489DavidStaffCustomer Support
Unfortunately that method only works with blocks where inline styles or static stylesheets are used. There isn’t a simple solution to getting the dynamic CSS GB uses, but we are working on something in GP to resolve that.March 25, 2020 at 7:05 am #1209496George
Oh, that’s great, thanks!March 25, 2020 at 7:07 am #1209501DavidStaffCustomer SupportMay 30, 2020 at 2:33 am #1307390Marcel
Unfortunately that method only works with blocks where inline styles or static stylesheets are used. There isn’t a simple solution to getting the dynamic CSS GB uses, but we are working on something in GP to resolve that.
Do you have some news about this solution? It would be great to hear a positive answer or at least an estimative deadline for that. Getting the dynamic CSS GB uses would be steroids for designers.
Thank you!May 30, 2020 at 6:13 am #1307528
- You must be logged in to reply to this topic.