• block: context

    Read more

    Used to create a context of data, for example between parent / children blocks.

    Example, making the post id accessible, in block.json:

    {
    	"$schema": "https://schemas.wp.org/trunk/block.json",
        ...
        "usesContext": [ "postId" ]
    }

    In render.php :

    $post_id = $block->context['postId'];

    In edit.json :

    export default function Edit( { attributes, setAttributes, context } ) {
    
    // context.postId
    
    }