Advertisement
grappler

Child theme load parent theme

Apr 13th, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Load the style sheet from the parent theme.
  4.  *
  5.  */
  6. function theme_name_parent_styles() {
  7.  
  8.         // Register the parent stylesheet
  9.         wp_register_style( 'theme-name-parent-style', get_template_directory_uri() . '/style.css', array(), '0.1', 'all' );
  10.  
  11.         // Register the parent rtl stylesheet
  12.         if ( is_rtl() ) {
  13.         wp_register_style( 'theme-name-parent-style-rtl', get_template_directory_uri() . '/rtl.css', array(), '0.1', 'all' );
  14.         }
  15.  
  16.         // Enqueue the style
  17.         wp_enqueue_style( 'theme-name-parent-style' );
  18.         wp_enqueue_style( 'theme-name-parent-style-rtl' );
  19. }
  20. add_action( 'wp_enqueue_scripts', 'theme_name_parent_styles' );
  21. ?>
  22. <?php
  23. /**
  24.  * Load the style sheet from the parent theme with current version number in the url.
  25.  *
  26.  */
  27. function theme_name_parent_styles() {
  28.  
  29.         // Define Parent theme
  30.         $theme  = wp_get_theme( 'theme-name' );
  31.  
  32.         // Register the parent stylesheet
  33.         wp_register_style( 'theme-name-parent-style', get_template_directory_uri() . '/style.css', array(), $theme['Version'], 'all' );
  34.  
  35.         // Register the parent rtl stylesheet
  36.         if ( is_rtl() ) {
  37.         wp_register_style( 'theme-name-parent-style-rtl', get_template_directory_uri() . '/rtl.css', array(), $theme['Version'], 'all' );
  38.         }
  39.  
  40.         // Enqueue the style
  41.         wp_enqueue_style( 'theme-name-parent-style' );
  42.         wp_enqueue_style( 'theme-name-parent-style-rtl' );
  43. }
  44. add_action( 'wp_enqueue_scripts', 'theme_name_parent_styles' );
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement