[wp-trac] [WordPress Trac] #55184: Custom style handle attached to a custom block style is never load even if the block is in the page.

WordPress Trac noreply at wordpress.org
Thu Feb 12 00:02:29 UTC 2026


#55184: Custom style handle attached to a custom block style is never load even if
the block is in the page.
-------------------------------------------------+-------------------------
 Reporter:  alexandrebuffet                      |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  7.0
Component:  Script Loader                        |     Version:  5.9
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch changes-requested needs-   |     Focuses:
  unit-tests                                     |
-------------------------------------------------+-------------------------

Comment (by westonruter):

 Here's the PHP code extracted from [attachment:"block-styles.png"]:

 {{{#!php
 <?php
 /**
  * Registers block styles stylesheets.
  *
  * @since My Theme 1.0.0
  *
  * @return void
  */
 function my_theme_register_block_style_stylesheets() {

         wp_register_style(
                 'my-theme-post-terms-style-labels',
                 get_template_directory_uri() . '/assets/css/blocks/post-
 terms/style-labels.css',
                 array(),
                 MY_THEME_VERSION
         );

 }

 add_action( 'enqueue_block_assets',
 'my_theme_register_block_style_stylesheets' );
 add_action( 'admin_enqueue_scripts',
 'my_theme_register_block_style_stylesheets' );

 /**
  * Registers block styles.
  *
  * @since My Theme 1.0.0
  *
  * @return void
  */
 function my_theme_register_block_styles() {

         register_block_style(
                 'core/post-terms',
                 array(
                         'name'         => 'labels',
                         'label'        => __( 'Labels', 'my-theme' ),
                         'is_default'   => true,
                         'style_handle' => 'my-theme-post-terms-style-
 labels',
                 ),
         );

 }

 add_action( 'init', 'my_theme_register_block_styles', 9 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55184#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list