[wp-trac] [WordPress Trac] #36592: enqueue child theme with parent resource dependency and version shows child version

WordPress Trac noreply at wordpress.org
Thu Jun 16 14:26:11 UTC 2016


#36592: enqueue child theme with parent resource dependency and version shows child
version
--------------------------+-------------------------
 Reporter:  Twintails     |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Themes        |     Version:
 Severity:  normal        |  Resolution:  worksforme
 Keywords:                |     Focuses:  template
--------------------------+-------------------------
Changes (by ocean90):

 * status:  new => closed
 * resolution:   => worksforme
 * version:  trunk =>
 * component:  Script Loader => Themes
 * milestone:  Awaiting Review =>


Comment:

 Hello @Twintails, welcome to our Trac!

 `wp_get_theme()` falls back to `get_stylesheet()` if the first argument
 isn't set. `get_stylesheet()` returns in this case the value for the child
 theme. You have to pass `get_template()` to `wp_get_theme()` to get the
 theme object of the parent theme:

 {{{#!php
 <?php
 $the_parent_theme = wp_get_theme( get_template() );
 wp_register_style( 'my-parent-style', get_template_directory_uri() .
 '/path/to/style.css', array(), $the_parent_theme->get( 'Version' ), true
 );

 $the_child_theme = wp_get_theme( get_stylesheet() );
 wp_register_style( 'my-child-style', get_stylesheet_directory_uri() .
 '/path/to/style.css', array( 'my-parent-style' ), $the_child_theme->get(
 'Version' ), true );
 }}}

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


More information about the wp-trac mailing list