Support Forum
Hello,
I created a Gutenberg block and it renders fine but it's adding <p></p> like wpautop is running on the block template. I tried using the standard:
remove_filter('the_content','wpautop');
remove_filter('render_block','wpautop');
But nothing happens!
What am I doing wrong?
Here is my code to create the block:
// Video Background Section
$meta_boxes[] = array (
'title' => esc_html__( 'Video Background', 'text-domain' ),
'id' => self::PREFIX.'video-background',
'fields' => array(
array (
'id' => self::PREFIX . 'join_button_text',
'type' => 'text',
'name' => esc_html__( 'Join Button Text', 'text-domain' ),
'std' => 'Join Now',
),
array (
'id' => self::PREFIX . 'heading',
'type' => 'text',
'name' => esc_html__( 'Heading', 'text-domain' ),
'std' => 'Grow your piano studio',
),
array (
'id' => self::PREFIX . 'subheading',
'type' => 'textarea',
'name' => esc_html__( 'Sub Heading', 'text-domain' ),
'std' => 'Refresh your teaching, supercharge your business and feel supported every step of the way.',
),
array (
'id' => self::PREFIX . 'play_video_button_text',
'type' => 'text',
'name' => esc_html__( 'Play Video Button Text', 'text-domain' ),
'std' => 'Play Video',
),
),
'category' => self::CATEGORY,
'render_template' => lpg_get_plugin_path().'blocks/video-background.php',
//'enqueue_style' => lpg_get_plugin_path().'blocks/video-background.css',
'icon' => 'video-alt2',
'keywords' => array(
0 => 'video',
1 => 'background',
2 => 'top',
3 => 'header',
4 => 'hero',
5 => 'jumbotron',
),
'supports' => array(
'align' => ['wide', 'full'],
'customClassName' => true,
),
'description' => 'Video Background',
'type' => 'block',
'multiple' => false,
'enqueue_assets' => $this->load_gutenberg_styles('video-background'),
);
return $meta_boxes;
Hi Mauro,
I tried your code and didn't see any problem with wpautop. Please see my video:
https://www.loom.com/share/22373c8a9cf74fc18bbd401ca2b56ff0
Maybe I'm missing something.
I'm missing something too!
I tried adding other blocks and the wpautop is applied to them as well, so this is not an issue with MetaBox. I also tried changing the theme so it's not an issue with the theme.
I guess it's a problem introduced by one of the other plugins.
I managed to solve this bypassing the_content and loading the blocks like this:
if ( has_blocks( $post->post_content ) ) {
$blocks = parse_blocks( $post->post_content );
foreach( $blocks as $block ) {
echo render_block( $block );
}
}
Thanks for looking into this Anh, your help is precious and always appreciated!
M.