0

I have several Gutenberg blocks. I'd like them not to show up together in frontend inside the_content. I'd like to use them for other purposes, so I would need to query them (get their contents) one by one, store in memory and then place them where I want. Is it possible? Can't find docs about.

1

1 Answer 1

1

My own answer is: somewhat yes, but not so easily. We can use 2 functions:

https://developer.wordpress.org/reference/functions/parse_blocks/

https://developer.wordpress.org/reference/functions/render_block/

Not very well documented yet. But you can pass raw content to parse_blocks to have them back in array form.

The thing is that they don't have some sort of ID. So this approach is not always usefult, depending on what you want to do with them.

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.