GardenTools & experiments

Keeping WordPress changes in a child theme

An earlier child-theme setup and the need for the directory, parent template, and styles to agree.

A WordPress child theme keeps site-specific template and style changes separate from a parent theme’s files. The original note created a directory and copied the template it wanted to change:

cd /home/nhancv/workspace/nhancv.com/wp-content/themes/
sudo mkdir chicken-child
sudo cp chicken/footer.php chicken-child/

It also recorded a theme-listing screenshot:

Create image file in PNG Format having name screenshot.png and save it in themes root folder.The recommended image size is 880x660. Even recommended image size is 880x660 though it will only be shown as 387x290 but the double-sized image allows for high-resolution viewing on HiDPI displays.

or just copy from parent theme
$ sudo cp chicken/screenshot.png chicken-child/

Match the parent deliberately

sudo nano chicken-child/style.css

# Config content

/*
Theme Name: Freddo Child Theme
Theme URI: https: //nhancv.com
Description: freddo child theme
Author: nhancv
Author URI: https://nhancv.com
Template: freddo
Version: 0.1
*/
@import url("../freddo/style.css”);
.wp-block-preformatted, .wp-block-code, code, kbd, tt, var {
    font-size: 12px;
    font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
    font-weight: 400;
    border-spacing: 0;
    line-height:1.4;
    white-space: pre;
}
input[type="checkbox"], input[type="radio"] #wp-comment-cookies-consent {
    margin: 5px;
}
.site-branding img {
    height: 40px !important;
    margin-right: 5px;
}
.freddoSubHeader, .site-branding, .freddoLogo, .freddoTitleText {
    display: flex;
    align-items: center;
}
.freddoTitleText {
    flex-direction: column;
    align-items: start;
}

The earlier shell examples use chicken, while the stylesheet declares freddo as the parent. Those names must agree with the actual installed theme. The CSS import also contains a typographic closing quote; this mixed shell/stylesheet listing is not valid unchanged.

Check ownership before activation

sudo chown www-data:www-data -R /home/nhancv/workspace/nhancv.com/wp-content/themes/chicken-child

The source activated the child through the dashboard afterward. A recursive ownership change is an operational choice, not an automatic requirement for every installation. The WordPress child-theme reference explains the parent/child contract. No theme files on the original site were changed.

← Back to the garden