256 Kilobytes

Forum in Content-Management Systems | By Some Guy

Published 7 months agoTue, 04 Dec 2018 17:55:43 -0800

98 views, 0 RAMs, and 1 comment

Profile Photo - Some Guy Some Guy
🗎 3224 🗨 41 🐏 31

I need to modify my theme and add some functionality but I don't want to edit the core files, I've read that I can set up a child theme but I'm unsure exactly how this is done. 

Can you help please?


Download more RAM. 🐏 ⨉ 0 Posted by Some Guy 7 months ago 🕓 Posted at 04 December, 2018 17:55 PM PST

This is a patsy account used by the 256 Kilobytes staff to seed content. 

Profile Photo - Hash Brown Hash Brown Internet Activist &... United State of Euro...
🗎 59 🗨 395 🐏 183

Well done for not editing core files like 95% of the internet.

You're correct, if you want to modify a theme in wordpress you need to build a child theme. These are essentially themes where the parent theme is the fall back option if the child theme does not have the file/code it needs to run.

The easiest way to do this is with a FTP client, log in using your credentials and navigate to:

Root folder/wp-content/themes

From here, you're going to need to make a new folder, call it "child-theme".

Here, we need to make a file called style.css

We need to edit this file and add the following block of code:

 Theme Name:   Twenty Fifteen Child
 Theme URI:      http://example.com/twenty-fifteen-child/
 Description:  Twenty Fifteen Child Theme
 Author:       John Doe
 Author URI:     http://example.com
 Template:     twentyfifteen
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:    http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  twenty-fifteen-child

The following is the bare minimum that you need to edit:

  • Theme name - this needs to be unique to your new child theme.
  • Template - this needs to be the directory name of your parent theme.

You can edit the rest as you wish, they have no impact over how the theme works.

Next, we need to make another file called functions.php

Inside this file we need a function that enqueues the parent themes CSS. You could use @import but you're going to increase load times and it can cause CSS to be loaded twice depending on the parent theme also so the latest method is a wp function.

Add this to your child themes functions.php file.

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
    $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),

You need to edit the $parent-style variable for your theme.

This sets the parent theme style.css as a fall back to your child themes css. This also sets version numbers to help bust cache later on.

If your parent theme has multiple CSS files (such as style.css/main.css/somethingelse.css) you will need to make sure they are brought in as well.

From here you set the child theme to be active on your wordpress site and you're now free to go on.

Something to keep in mind is the functions.php file for your child theme does not overwrite the parent themes functions.php file, it works in addition to. This can create conflict so keep this in mind if experiencing issues.

Hope this helps

Download more RAM. 🐏 ⨉ 0 Posted by Hash Brown 7 months ago

Edit History

• [2018-12-05 14:18 PST] Hash Brown (7 months ago)
🕓 Posted at 05 December, 2018 14:18 PM PST


Post a New Comment

To leave a comment, login to your account or create an account.

Do you like having a good time?

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account
You can also login to an existing account or recover your password. All use of this site is subject to terms outlined in the terms of service and privacy policy.