Using a child theme

Create a Goodnews child theme so your changes survive every theme update.

Goodnews does not ship a child theme, but WordPress's standard child theme mechanism works with it. If you plan to edit any PHP file, or add more than a small amount of CSS, do it in a child theme rather than editing goodnews5 directly.

Create the child theme

  1. On your computer, create a new folder, for example goodnews5-child.
  2. Inside it, create a file named style.css with this header:
/*
Theme Name: Goodnews Child
Template: goodnews5
Version: 1.0
*/

The Template line must be goodnews5 exactly — it is what tells WordPress which theme this is a child of.

  1. Create a second file named functions.php. Load the parent theme's stylesheet before your own, so your rules can override it:
add_action('wp_enqueue_scripts', function () {
    wp_enqueue_style(
        'goodnews-parent-style',
        get_template_directory_uri() . '/style.css',
        [],
        wp_get_theme()->parent()->get('Version')
    );
    wp_enqueue_style(
        'goodnews-child-style',
        get_stylesheet_uri(),
        ['style', 'goodnews-parent-style']
    );
});

'style' is the handle the theme's own main stylesheet is registered under. Listing it as a dependency makes sure your child theme's rules load after it, so they can override it.

  1. Upload the goodnews5-child folder to wp-content/themes/ — the same place goodnews5 lives.
A child theme folder containing style.css and functions.php.

Activate it

Go to Appearance → Themes and activate Goodnews Child. Your site looks exactly the same, because the child theme has not changed anything yet — it is now the active theme, and goodnews5 supplies everything the child does not override.

WordPress Themes screen with the Goodnews child theme active.

Overriding CSS

Add your rules to the child theme's style.css, below the header comment. They load after the parent's styles, so a rule with equal specificity wins:

.site-header {
  background-color: #111111;
}

Overriding a template file

To change a specific template — a single post layout, for example — copy the file from goodnews5 into goodnews5-child, keeping the exact same path. WordPress uses the child theme's copy instead of the parent's.

Adding PHP behavior

Add functions to your child theme's functions.php, using WordPress's hooks — add_action and add_filter — rather than editing the parent theme's files. This keeps your customizations in one place and out of the way of updates.