After recent updates to Astra and Toolset, I found that sites using a custom loop would no longer output the loop. Instead they would only output the content from the page they were added to.
I contacted the Astra support team and they provided the following code, which "fixed" the issue:
function remove_inner_group_container_filter( $block_content, $block ) {
$group_with_inner_container_regex = '/(^\s*<div\b[^>]*wp-block-group(\s|")[^>]*>)(\s*<div\b[^>]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/';
if (
( isset( $block['blockName'] ) && 'core/group' !== $block['blockName'] ) ||
1 === preg_match( $group_with_inner_container_regex, $block_content )
) {
return $block_content;
}
$replace_regex = '/(^\s*<div\b[^>]*wp-block-group[^>]*>)(.*)(<\/div>\s*$)/ms';
$updated_content = preg_replace_callback(
$replace_regex,
function( $matches ) {
return $matches[1] . $matches[2] . $matches[3];
},
$block_content
);
return $updated_content;
}
add_action( 'after_setup_theme', 'remove_render_block_filter' );
function remove_render_block_filter() {
remove_all_filters( 'render_block' );
add_filter( 'render_block', 'remove_inner_group_container_filter', 99, 2 );
}
Hello,
Thanks for sharing the solution, it will help other users.
Did you need more assistance for it?
Hi Luo
I was hoping that there might be an update coming to Toolset that would address the issue, rather than having to rely on a workaround.
If that's not going to be the case, please just let me know.
As I understand from the custom codes you mentioned above, Astra plugin/them was using filter hook render_block to change outputs of all WordPress blocks, and above codes can remove their custom filters when this block is a non WordPress built-in(core/group) block.
I don't think we can apply their custom codes in Toolset plugins, you might ask Astra support to apply their fix in Astra plugin/theme
Thanks, Luo. I'll follow up with the Astra support team.