No, you don’t make changes to the parent theme – that’s the point of a child theme. You only put CSS changes in the child theme – don’t copy the entire parent CSS.
For php files, make a copy of the file and put the copy in the child theme and make changes there.
For functions, it’s more complicated – please review:
http://codex.wordpress.org/Child_Themes
So if i have in the style.css this lines of code:
.slider
{
position: relative;
width: auto;
display: block;
overflow: hidden;
margin-bottom: 25px;
margin-top: 25px;
}
And i want to change some things such as the “margin-bottom: 50px;” and to delete the “margin-top: 25px;” what i have to do?
Just insert in the child’s theme folder, in the style.css the line code below?
.slider
{
position: relative;
width: auto;
display: block;
overflow: hidden;
margin-bottom: 50px;
}
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Yes, or just the style you want to change;
.slider
{
margin-bottom: 50px;
}
And with the php files? I really can’t understand how to do it.. Can anyone give me an example?
If you want to change something in the header.php file, make a copy of that file (on your local computer), change the code you want to change – let’s say, move the navigation to the top of the page from its original position below an header image – and upload the new header.php version to the child theme using FTP. Then, depending on the change you made, you might need to also change the CSS code.
Or you might want to change the code that pulls posts onto a page – in which case you would change the code in the template file you are using — i.e. index.php or whichever it is.
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Example: You have Twenty Twelve and a Twenty Twelve Child Theme.
You have these directories under /wp-content/themes/
twentytwelve
twentytwelvechild
Both directories have some files like these inside:
twentytwelve
- 404.php
- archive.php
- author.php
- category.php
- comments.php
- content-aside.php
- style.css
... and so on
twentytwelvechild
- style.css
The scenario:
You want to modify author.php.
You just copy author.php from twentytwelve directory and paste it into twentytwelvechild.
E.g your directory and files will be;
twentytwelve
- 404.php
- archive.php
- author.php
- category.php
- comments.php
- content-aside.php
- style.css
... and so on
twentytwelvechild
- style.css
- author.php
So you can now modify author.php from within twentytwelvechild.
OK! Thank you! If i need something else i will reply!
Guys! To make the changes do i have to delete the code lines from the parent’s theme?
No, the CSS you add to the child theme overrides (or should override) the parent theme styles. If it’s not doing that, your CSS is usually either not valid and/or not “specific” enough. If you need to learn some more about CSS, this is a good site:
http://www.w3schools.com/css/
My problem is that if in the parent theme i have this code:
.header {
margin-top: 10px;
margin-left: 10px;
position: relative;
}
and i want to delete the position: relative; and change the margin-top: 10px; to margin-top: 15px;
What i have to do? Will i put this code lines in the style.css in the child theme?
.header {
margin-top: 15px;
margin-left: 10px;
}
Please clear my mind because its all mess in here!
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
You add;
.header {
margin-top: 15px;
position: initial;
}
Why do i put position initial? I mean if i don’t want to include a code line from the parent theme do i have to delete it or just ignore putting it in the child’s theme style.css? Because if i delete it in the parent’s theme, after an update it will replace it and added the code line again.