• Resolved jgoldberg2013

    (@jgoldberg2013)


    Here is a rather simple question for which I honestly can not find the answer to.
    I know when creating a child theme – you have the standard data ending in @import url("../responsive/style.css"); to link to the stylesheet.
    QUESTION: Do you do have to have the “@ import” when creating other files in the child them. Like functions, page, header etc…
    Example: `@import url(“../responsive/header.php”);
    or can one just place the new CSS or html into a file called header.php.
    Seems like an honest question but no direct answer could be found.
    Lastly – if you want to edit something that is found in the header.php file – do you have to create header.php in child theme and place new code there in order to not loose on updates or can you place it in the child style sheet?

Viewing 8 replies - 1 through 8 (of 8 total)
  • No.

    You only put CSS in the style.css file. Do not put it in any .php files.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Maybe jgoldberg2013 means do you have to have a style.css file to have a Child Theme; can you have just a header.php file with internal CSS in your Child Theme instead(?).

    Sorry, the above was not a very good answer – no @import only goes in the style.css file.

    If you want to modify the header.php file, yes, make a copy of that file in your child theme and make the changes there. But CSS does not go in any .php files.

    Do not put anything in the style.css file except CSS code.

    QUESTION: Do you do have to have the “@ import” when creating other files in the child them.

    Nope. As long as the comment block is there at the top, that’s all you actually need for a child theme. However, in what situation wouldn’t you want to import the parent’s CSS? Wouldn’t you – in effect – almost be creating a new theme? If so, why bother with a child., Why not go the rest of the way and create a brand new standalone theme?

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    Ok – got it thanks.
    Just to clarify…and as an example.
    If I wanted to change the header height and the code for this is in the header.php.
    Do I copy the complete file into child theme directory and only edit what I need to change or can I only place my new code in the new header.php file with nothing else?
    Just want to make sure as this is basic stuff that no one actually covers in any forum I have read.

    You would need to make a copy of the parent’s header.php in the child theme and then modify the child’s copy. There isn’t really an @import equivalent for template files like there is for CSS.

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    Esmi Theme Diva – I am not sure what you are saying as I was merely trying to qualify a very simple thing.
    As a newbie and learner in this – all one reads is create a child them if you want to make any changes so in the event of updates you do not loose your changes. I was only posing this question because from what I have read so far is that in some situations one would have to add or change code in the header / page files.
    I most certainly do not want to create a new theme. Maybe in 3 years time.
    Thanks anyway.

    Thread Starter jgoldberg2013

    (@jgoldberg2013)

    Thanks esmi for the final comment on given. that really sums up inquiry – I may have jumped the mark a bit with my comment to you.
    Again thanks
    [Resolved]

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘@ import for child theme: simple question’ is closed to new replies.