[Resolved] Add reusable Gutenberg Block via Hook in Generatepress Elements

Home Forums Support Add reusable Gutenberg Block via Hook in Generatepress Elements

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #975975
    Michael

    Hey there,

    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?

    Thank you.
    Best regards
    Mike

    #976014
    David
    Staff
    Customer Support

    Hi there,

    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 );
    ?>

    Replace XXXX with 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.

    #976034
    Michael

    Hi David,

    awesome. That worked.

    Thank you very much!
    Best regards
    Mike

    #976041
    David
    Staff
    Customer Support

    Great! – glad to be of help

    #1209484
    George

    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?

    #1209489
    David
    Staff
    Customer 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.

    #1209496
    George

    Oh, that’s great, thanks!

    #1209501
    David
    Staff
    Customer Support
    #1307390
    Marcel

    Hello.

    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!

    #1307528
    David
    Staff
    Customer Support

    Hi there,

    it will be a primary feature in GP Premium 1.11. No definitive time line on that update but i would expect in the next couple of months.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.