• Hi,
    I am very, very beginner on WordPress themes or codes or anything.

    I’m using Sliding Door theme. I saw that you should create a Child Theme (style.css) so i did, and it seems to be working fine. I want to add a widget to my sidebar and the instructions (from the widget source) said to add their code to my functions.php. I am also going to use a custom logo, so thinking I also need to bring my header.php into my child theme??? So, i am trying to figure out how to get my functions.php and header.php into my Child Theme. I’m clueless and just don’t want to lose my changes when WP updates, as everyone is saying i will.

    Thank you in advance for your help.

Viewing 15 replies - 1 through 15 (of 19 total)
  • To use your functions.php and header.php files in your child theme all you need to do is add those two files to your child themes folder. They will be used automatically.

    Thread Starter allforjc2

    (@allforjc2)

    Hi Michael,
    Thank you for your reply.

    Do i actually copy and paste all of the code and everything from the original parent functions.php and add a file to Child Theme folder or is there some type of import rule like there was with the style.css?

    No, you don’t do anything more then add your new code into the functions.php file. WordPress takes care of it all behind the scenes.

    This is different for the template files like header.php where that whole file will be used instead of the header.php file in your parent theme. I normally start by doing a full copy-and-paste with these files so I have a known starting point and then move on to do my modifications after that.

    Thread Starter allforjc2

    (@allforjc2)

    Ok, sorry, like i said i’m very beginner.

    So, functions.php – I go into my Child Theme folder and create a completely blank file named “functions.php” the same as its parent – no different name like the Child Theme needed when i did style.css. This file sits right alongside my style.css

    header.php – I can just copy and paste original file into Child Theme folder, and it sits right alongside style.css and functions.php.

    I’m putting this in baby terms so i get it. : )

    So then is this similar to the Hierarchy rule that i’m hearing, where the system looks to the Child Theme first?

    Yes that’s right.

    The only thing that you need to have in your child theme’s functions.php file is the opening PHP tag right at the start:

    <?php

    Everything else is up to what you want to add into it.

    The template files are the same as you say too. The easiest way to find out where these go is to look in your parent theme. The files in there will tell you where your child themes files need to be.

    Obviously there is more to it then just that, but that’s a good starting point, and it seems like you’re getting the ideas right from the start (which is the biggest part of the battle).

    Thread Starter allforjc2

    (@allforjc2)

    Thank you Michael.

    I’ve been trying to figure this out for weeks! I’ve been so confused and frustrated! I’m getting it because you are speaking nice clear directions. Thank you for that.

    I’ll give it a go…

    Thread Starter allforjc2

    (@allforjc2)

    Well, i must have done something wrong. It all seems to be right, but i am getting this error message and it won’t let me get to my site.

    Parse error: syntax error, unexpected $end in /home/allforjc/public_html/wp-content/themes/slidingdoorchild/functions.php on line 1

    A friend said it was probably because you can’t have the same names as the parent. I tried adding a letter before the name (ie. cfunctions.php) and it lets me in to themes-editor and shows both files. Not sure if they actually work though.

    Any suggestions?

    No, renaming the file is not the right thing to do. If you rename it, WordPress won’t be able to find it.

    An error of “unexpected end” normally means that something isn’t right with that file. Seeing as how it’s on line 1, that’s a worry.

    Can you post the first couple of lines of code so that we can see what you have? That might help to see where the error is. Remember that the line number that’s shown isn’t always the line that the error actually occurs on, so it’d be good ot give us a few (5 or 10 lines) to be sure. And remember, no passwords, ID’s, etc in the code. šŸ™‚

    Thread Starter allforjc2

    (@allforjc2)

    Hi,
    Sorry i had to run my son down the street.
    Are you referring to the code at my host server? Because my themes-editor won’t let me in.

    Yes, the code that’s in your functions.php file.

    Thread Starter allforjc2

    (@allforjc2)

    This is all that is in the Child Theme functions.php

    functions.php
    PHP script text
    <?php

    Are you going to have some extra code in your functions.php file? If si, put a bit in there now, even if it’s only a comment. That way it will have some content in it, and that should stop this error message from showing.

    If you are not going to have anything custom in that file, just delete the file. It doesn’t have to be there if it doesn’t do anything. The only required file for a child theme is the style.css file.

    Thread Starter allforjc2

    (@allforjc2)

    Originally I was trying to put a Widget in, and the widget source said to put it in my functions.php. Like i said, i’m beginner on this. I don’t know if i need the functions.php or the header.php. Only reason for header.php was because i was going to use a custom logo and thought i needed it to do that…

    and i don’t know how to write a comment in there. Doesn’t it need some kind of characters? (*/)

    Yes, if you are adding a widget, it will need to go into the functions.php file. There’s a couple of different ways to do this, like I normally keep widgets in their own files to keep it all a bit cleaner, but that’s a bit more of an advanced discussion, so can be saved for another day.

    I don’t know what options there are in yoru theme, but some allow you to add your own custom logos, so it’s worth a look tehre first. If not you can change the HTML code in the header.php fie to point to the new logo file.

    Comments in PHP are done in one of two ways:

    Single-line comments have // in fron tof them like

    // This is a comment line

    Multi-line comments start and end with /* and */ like

    /*
    This is a multi-line comment.
    And so is this!
    */

    This may seem like a lot to think about, but after doing it a few times you’ll get the hang of it. šŸ™‚

    Thread Starter allforjc2

    (@allforjc2)

    Ok, so basically I’m going to go in and add a comment to functions.php and see what that does.

    The custom logo – My theme actually let me bring a custom .jpg photo into the header. Actually it replaced the Site Title. I have that Firebug from Firefox (still very confusing) and i figured out what element Site Title was and i replaced it with the photo then pasted into my style.css file and it works fine. Maybe i don’t need the header.php file??

    I’m going to add the comment….

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘How do I get my functions.php & header.php into my Child Theme?’ is closed to new replies.