0

Is there a way/ a function to insert a block and user reusable blocks from inside a php page/template-part like use_block('jetpack/google-calendar') to a block?

(I am using a partial block theme, since block theme doesn't have support for all the features I want to use, but I still want the site to look uniform and not to use different styles for the same section)

I have looked all over https://developer.wordpress.org/?s=block but I didn't find any suitable thing.

1
  • 1
    I followed the search link and I saw the exact solution to your question in the top 2 results, it was the very first function listed ( hint: what's the difference between pre-declared blocks and post content? There is none, you copy paste from the editor with the block markup )
    – Tom J Nowell
    Commented Jan 31, 2023 at 14:12

1 Answer 1

0

You can use do_blocks and insert block content as string in that function, which will like do_shortcode transform block's html and metadata in html comments into final html.

I am not sure if it works for reusable blocks, I never used them.

If you want to use block theme, you should develop your own blocks for any missing features. This is nowadays much easier than it used to be, you can tweak existing blocks, create block variants, block styles, enqueue extra style for core blocks (wp_enqueue_block_style) etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.