Random WordPress Function

Learn about a new WordPress function every day!


Function Signature:

wp_register_layout_support

Function Description:

Registers the layout block attribute for block types that support it.

Function Examples:

⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Register a custom layout support for a theme
function custom_theme_layout_support() {
    add_theme_support( 'custom-layout' );
}
add_action( 'after_setup_theme', 'custom_theme_layout_support' );
wp_register_layout_support( 'custom-layout' );
// Example 2: Register multiple custom layout supports for a theme
function custom_theme_layout_support() {
    add_theme_support( 'custom-layout1' );
    add_theme_support( 'custom-layout2' );
}
add_action( 'after_setup_theme', 'custom_theme_layout_support' );
wp_register_layout_support( 'custom-layout1' );
wp_register_layout_support( 'custom-layout2' );
// Example 3: Register a custom layout support with specific options
function custom_theme_layout_support() {
    add_theme_support( 'custom-layout', array(
        'default' => 'sidebar',
        'choices' => array(
            'sidebar' => 'Sidebar Layout',
            'full-width' => 'Full Width Layout'
        )
    ) );
}
add_action( 'after_setup_theme', 'custom_theme_layout_support' );
wp_register_layout_support( 'custom-layout' );