• Hello!

    I want to create a child theme and i can do that until the point i install it. That i want is to know how can i use it to make the changes i want!

    To be more specific!

    I created a child theme and installed it. I want to make some changes in the parent theme, so where do i put the changes? Do i insert the whole style.css code from the parent’s to the child’s theme style.css or do i have to insert only the changes i want in the child’s theme?

    What i have to do with the .php files? For example, if i want to change some code lines in the parent theme do i have to create a new .php file in the child’s theme folder and insert the whole code with the changes?

    Please make all the things in my mind clear because i am confused!
    Also if you have some guide on how to use the child theme (not how to create it) it would be very useful.

    Thanks mates!

Viewing 12 replies - 1 through 12 (of 12 total)
  • 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:

    https://codex.www.ads-software.com/Child_Themes

    Thread Starter e-win.gr

    (@haritos)

    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;
    }

    Thread Starter e-win.gr

    (@haritos)

    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.

    Thread Starter e-win.gr

    (@haritos)

    OK! Thank you! If i need something else i will reply!

    Thread Starter e-win.gr

    (@haritos)

    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:

    https://www.w3schools.com/css/

    Thread Starter e-win.gr

    (@haritos)

    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;
    }

    Thread Starter e-win.gr

    (@haritos)

    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.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How can use the child theme?’ is closed to new replies.