2

I just learnt about creating child themes from the Codex , it says to add

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}

and

function theme_enqueue_styles() {

    $parent_style = 'parent-style';

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style )
    );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); 

in my child theme's functions.php file but it did not address the issue when our parent theme has more then one style sheet(.css files). (In my case twenty-fourteen theme has two style.css and rtl.css) and two more in /css folder named editor-style.css and ie.css So what I have to change in the code above to load both stylesheets.

I have gone through this question but it did not address my issue.

2

Twenty fourteen loads its stylesheets differently in that it made the main stylesheet dependant on the genericon stylesheet, and I'm sure that this is the problem you are experiencing. (if not, please update your question with proper details)

You can change how you enqueue your style in the first block of code as follow

wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array( 'genericons' ) );

EDIT

You have a misunderstanding about how certain stylesheets are loaded. The child theme loads all stylesheets from the parent except the parent stylesheet. That is how the system was build. Now, there are stylesheets that are not loaded by the theme, but by Wordpress by default

  • editor-style.css get loaded automatically on the TinyMCE editor. Please see the codex for a full explanation

  • rtl.css only gets loaded when the website is set to a rtl language. On ltr languages like English, the stylesheet is not loaded. This is also done by default by Wordpress. Just a note, why would you want to load your rtl stylesheet on a ltr site. It is a waste of resources for one

  • ie.css The ie stylesheet is only loaded when the current browser is IE8 or older. That is the whole purpose of the ie stylesheet. IE8 and older does not support media queries, so other styles needs to be loaded on that browser.

The only code you need in your child functions.php is the following

function theme_enqueue_styles() {

    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css', array( 'genericons' ) );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( 'parent-style' )
    );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); 
  • actually all four (mentioned in the question) stylesheets are not being loaded by child theme by the code above. – Chaudhry Waqas Jul 9 '15 at 12:06
  • this is my functions.php file link – Chaudhry Waqas Jul 9 '15 at 12:15
  • You cannot use the same handle for all stylesheets, it will not work – Pieter Goosen Jul 9 '15 at 12:29
  • Also, you cannot redeclare the same function name, you'll get a fatal error – Pieter Goosen Jul 9 '15 at 12:30
  • I know it , please give me a solution instead :) – Chaudhry Waqas Jul 9 '15 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.