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.
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.