Child theme creation and the use of the @import in the style css?

I am using the Opulus theme from nimbus themes and wanting to create a child theme. I was looking at some threads on the internet and from the reading of these threads I am not certain when to use or if I should use the @import url("../mainthemename/style.css");.

Could some please clarify on the use of when to use the @import or not to use it?

Thank you
Doug

  • Patrick
    • Support Monkey

    Hey there @Huckleberry Press

    I hope you're having a great day!

    Yes, the @import rule is required for a child-theme as the base style-sheet in many themes is located inside a folder. So the relative path to that style-sheet must be defined in a child-theme style.css file.

    The only required element to get a functional child-theme is a style.css file with the following information in it:

    /*
    Theme Name: Child-theme Name
    Template: parent-theme-folder-name
    */
    @import url("../parent-theme-folder-name/style.css");

    Add that file to a folder and name it anything you like. Then upload the folder to your site and enable it.

    You can then start to copy any templates you want to customize from the parent to the child, respecting the exact folder structure.

    The only file you cannot copy from the parent to the child is functions.php. If you need a functions.php in your child-theme, you must create that file.

    Here's the official doc on creating a child-theme:
    http://codex.wordpress.org/Child_Themes

    ...and a recent post on our blog to help guide you through it:
    https://premium.wpmudev.org/blog/create-wordpress-child-theme/

    I hope this helps! And thanks for being a member :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.