Hello and happy new year!
You have four options that you can use in php:
do_shortcode(‘[isw-block name=”hallo world”]’);
do_shortcode(‘[isw-block id=”123″]’);
— or —
global $ISWBlocks;
ISWBlocks->render_block_shortcode( array( ‘name’ => ‘hallo world’));
where the ‘name’ => ‘hallo world’ is the post_name or post_title and the output will be translated with WPML if installed
— or —
global $ISWBlocks;
ISWBlocks->render_block_shortcode( array( ‘id’ => 123 ));
where ‘id’ => 123 is the id of the block and the output will be translated with WMPL if installed
— or —
global $ISWBlocks;
ISWBlocks->render_block ( $id )
where $id is the block id and will be rendered without WPML translation
We do not offer a build-in way to render a whole region yet! So you either have to do a custom WPQuery to get all block post types that belong to a specific block region and render them using the above mentioned shortcodes or alternatively use the WPViews plugin or equivalent that creates and displays queries from the backend.
I hope this helps!
Thread Starter
efegue
(@efegue)
Thanks, Happy new year to you too!
I’ll add my custom code for a region then. A region is better, so my theme is not dependent on block ids, if they get deleted, we’ll have trouble.
The idea is to show some content in a column layout and I choose this plugin for this task, do you think this is the best solution to achieve this? I didn’t want to use posts or pages, because like I said, I would be relying on IDs and that’s a bad practice in my opinion.
In our projects, we usually use this plugin in conjunction with WP-Views(a commercial plugin from wp-types.com) in order to achieve what you are after as this gives us maximum flexibility and control over how this content is rendered.
We set up a custom view that selects all blocks for a specific region in WP-Views in a layout that we want to use(list, column, etc) and then insert that view where we want to display it.
Alternatively, you can achieve the same effect with a custom WPQuery in php.
Is there also a possability to render all blocks from a group?
Only using a WPQuery as descripbed above or custom plugin WP-Views or equivalent