Enqueue styles in child theme

  • Posted in : Readme
  • Monkette
    Participant

    I have created a Readme child theme but cannot get my styles to load. I am using the recommended enqueue function here: http://codex.wordpress.org/Child_Themes, and trying to load /css/main.css from the parent theme. There are multiple css files in the parent, do I need to load them all?

    If you could supply the proper function to load the styles I would greatly appreciate it.

    Mehmet S.
    Keymaster

    Hi, just add the following line to your child theme’s style.css file:

    @import url("../readme/style.css");
    

    Thanks

    Monkette
    Participant

    Thanks. I also got the enqueue method working, if anyone wants to use it:


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

    Mehmet S.
    Keymaster

    Ok. Good luck.

    loiselmaxime
    Participant

    More details on the enqueue method? I want to enqueue all the stylesheets from the parent Readme theme… But it’s not working

    serkan
    Moderator

    Hi loiselmaxime,
    For more details, I would recommend you to check out this related url.
    http://wordpress.stackexchange.com/questions/163301/versioning-import-of-parent-themes-style-css
    Thanks

    loiselmaxime
    Participant

    I have read it but still can’t get it right. Don’t you have a pre-made enqueuing script that loads properly all the css from the Readme theme? Thanks

    Mehmet S.
    Keymaster

    Hi, you can check out the following link for more information.

    https://developer.wordpress.org/reference/functions/wp_enqueue_style/

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register