Using Chap Child

Chap Child is the child theme of Chap. A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme.

You should always prefer to use the child theme over the parent theme.
Why use a Child Theme?
If you modify a theme directly and it is updated, then your modifications may be lost. By using a child theme you will ensure that your modifications are preserved.
Using a child theme can speed up development time.
So I only need the Child Theme?

No, child theme still requires the parent theme to also be installed. See our tutorial on how to install Chap parent and child theme here.

functions.php

Child theme’s functions.php file is executed even before the parent theme’s functions.php. You can use this file to add action hooks and filters. Since it’s a child theme, all the code will remain there after theme updates.

style.css

Custom CSS code can be added into this file and it will not be overwritten with theme updates. Custom CSS can also be added in the WordPress Customizer, with live preview, but keep in mind that this CSS will not be stored in any files, so when you move your child theme to a different host you will lose the custom styles unless you migrate the full database as well.

scripts.js

This file can be used to execute JavaScript on every page. The file already includes some structuring, which allows to reference jQuery by the $-sign and also add code that will be executed once the document is ready.

templates

Copy any template file from the parent theme folder chap/templates/ here to override it and modify to your liking.

lib/template-functions

Copy any action-*.php file from the parent theme folder chap/lib/template-functions/ here to override it and modify to your liking.
Any php file with “action-” prefix will be automatically loaded.

lib/widgets

Copy any widget-*.php file from the parent theme folder chap/lib/widgets/ here to override it and modify to your liking.
Any php file with “widget-” prefix will be automatically loaded.

It's possible to modify any widgets output by creating a file with a filter
PHP
namespace Chap\Widgets;
function the_widget_filter($widget_output, $props, $sidebar_id, $widget_type) {
  return $widget_output;
}
add_filter('chap_widget_WIDGET_ID', __NAMESPACE__ . '\\the_widget_filter', 10, 4);

One response to “Using Chap Child

Leave a comment

Your email address will not be published. Required fields are marked *