WP_DEBUG

Notes about WordPress Gutenberg themes development.

  • GitHub

.htaccess (1) ACF (7) admin (1) ajax (2) api (1) API interactivity (1) block (20) block_style (2) colors (2) constante (1) context (1) conventions (2) cron (1) css (5) custom post type (1) data (1) debug (2) define (1) file_API (1) functions.php (6) git (4) hook (7) i18n (2) js (2) layout (1) loop (1) media (1) media library (1) menu (2) navigation (1) patterns (1) performance (2) post (1) query (3) readmore (1) responsive (1) rest api (1) scss (1) security (7) spacing (1) sql (1) svg (1) taxonomy (1) theme (1) theme.json (11) typo (2) URL (1) wp-config.php (6) wp cli (3) wp function (7)

  • block: innerBlocks

    # block
    March 23, 2025
    Read more

    Option 1: InnerBlocks component

    index.js:

    import { InnerBlocks } from '@wordpress/block-editor';
    
    registerBlockType( metadata.name, {
    	edit: Edit,
    	save: props => { return <InnerBlocks.Content /> }
    ):

    render.php:

    <?php echo $content; ?>

    in edit.js:

    return (  <InnerBlocks { ...blockProps } /> )

    Option 2: useInnerBlocksProps hook

    This allow more control on the editor site. In edit.js:

    import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
    
    export default function Edit( { attributes, setAttributes } ) {
    
    	const MC_TEMPLATE = [
    		[ 'core/image', {} ],
    		[ 'core/paragraph', { content: 'Text content' } ]
    	];
    	const blockProps = useBlockProps( { className: 'sim-slide sim-slide-single-editor' } );
    	const innerBlocksProps = useInnerBlocksProps(
            blockProps,
    		{ template: MC_TEMPLATE },
    	);
    
    	return (
    		<div { ...innerBlocksProps } />
    	);
    
    }

    Source:

    • https://learn.wordpress.org/lesson/work-with-the-innerblocks-component/
    • https://make.wordpress.org/core/2021/12/28/take-more-control-over-inner-block-areas-as-a-block-developer/
    • https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/
WP_DEBUG

WP_DEBUG

  • GitHub