0

I want to add <ul><li><a href="link">Link</a></li></ul> to my theme's header.php. This is new code that doesn't already exist anywhere. I have created a child theme.

I've already put this code in parent theme and it works, but i want to do it correctly and use the child theme. So, if i create a header.php file in my child theme, and then say i put in that line of code, how would it know where the code goes relative to all the rest of the parent's header.php code?

I am guessing this is where i use actions, hooks, just not sure how to start. Or maybe i cut everything from the parent's file and paste it in . child's? That sounds like would work in theory but i can't imagine that's the right way.

How do i go about using the child's header.php to insert code into specific parts of the parent's header.php?

2
  • 2
    It doesn’t quite work like that. If you create a child theme and set that as your active theme then the header.php file from your child theme will be used instead of header.php from the parent theme. Parent theme files are only used if the equivalent file is missing from the active child theme. Commented Mar 14, 2019 at 20:00
  • Ok, that is helpful. Will try it and report back. Thank you.
    – Ben Blue
    Commented Mar 14, 2019 at 22:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.