• Resolved DPlugins

    (@dplugins)


    …blockProps only gives me values for currently edited values.
    How can i fetch global styles that i added under editor > styles > blocks > some-block

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @dplugins ,
    To fetch the global styles you added in WordPress under Editor > Styles > Blocks > Some Block, you can use the wp_get_global_settings or wp_get_global_styles functions. These functions are part of the WordPress block editor’s global styles API.

    $block_name = 'core/paragraph'; // Replace this with your block name, e.g., core/paragraph, core/image
    $global_styles = wp_get_global_styles( [ 'blocks', $block_name ] );

    if ( ! empty( $global_styles ) ) {
    echo ''; print_r( $global_styles ); echo '';
    }

    Fetch All Global Styles

    $global_styles = wp_get_global_styles();
    echo '<pre>';
    print_r( $global_styles );
    echo '</pre>';
    • This reply was modified 1 year, 4 months ago by bcworkz.
    Moderator bcworkz

    (@bcworkz)

    Hello @vijayraval,
    Thanks for contributing an answer! Just a reminder: please always place code suggestions within a Code block. When you do not, the forum’s parser corrupts your code, making it difficult for others to use. I’ve corrected the code in your reply to this topic.

    Thank you, @bcworkz , for providing information about the code block.

    Thread Starter DPlugins

    (@dplugins)

    Thanks a lot @vijayraval @bcworkz

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Access global custom block styles’ is closed to new replies.