Custom layouts in Astra theme is a very handy feature allowing you to display layout or content at a specific location or parts of the theme layout. By default, Gutenberg block editor is not enabled for custom layouts in the Astra theme. However, you can enable it to use blocks editor for creating content using custom layouts in the Astra theme.
Activate Blocks Editor for Astra Custom Layouts
In the WordPress Dashboard, go to Appearance > Theme Editor. Then open functions.php file of your Astra Child theme and add the following code at the end.
1 2 3 4 5 6 7 8 9 10 11 |
add_action( 'after_setup_theme', function(){ add_filter( 'register_post_type_args', 'wpd_enable_gutenberg_cpt', 10, 2 ); }); function wpd_enable_gutenberg_cpt( $args, $post_type ) { if( $post_type === 'astra-advanced-hook' ) { $args['show_in_rest'] = true; } return $args; } |
Save changes and now blocks editor option should appear for posts under “Custom Layouts” option of the Astra theme.
Leave a Reply