Genesis Child Theme – from scratch

More from this category




Genesis child from scratch (like god did)

https://wpengine.com/resources/create-theme-with-genesis/– additional article with "hooks" info
https://www.cloudways.com/blog/create-wordpress-genesis-child-theme-from-scratch/

How-to-create-genesis-child-theme-from-scratch

Before going into the heart of the matter and edit the templates, I would like to begin by answering a simple but important question: Why create your own WordPress theme? There are already many existing themes, many of which are of very good quality.

Moreover, embarking on such an adventure requires a lot of time and energy. Yes, but there are also a lot of benefits to creating your own WordPress theme and these are not negligible. According to WordPress developers:

  • Customization is not affected when parent theme is updated.
  • Inherits parent theme features.
  • The flexibility of customization without coding the whole theme.

We will go through the steps to create Genesis child theme from scratch. Of course, this is not a complete training given the breadth of WordPress, but this article will guide you on a solid foundation to start your project on the right foot.

Genesis Child Theme Files

Create a new folder inside wp-content > themes and give it a name of your choice. We are naming our file as Custom.

Now inside your child theme folder, create the following three new files:

  • functions.php
  • style.css
  • front-page.php

1. Functions.php File

This file contains our custom functions which we will create in our Genesis child theme to modify default functionality of Genesis as well as WordPress itself.

For this, open the file in text editor and start with adding standard documentation in the form of doc block.

[code style="php"]]<?php

/**

This piece of a document contains information regarding our theme name, its author, the link where its hosted and the license type.

Visit codex.wordpress for detailed information on functions.php file in WordPress.

The next line of code we are adding will initialize the Genesis framework. There are two methods of doing so. First, by referencing ini.php file inside your functions.php file and second which we will be using in the tutorial is by hooking our code into the Genesis setup function.

[code style="php"]add_action( ‘Genesis_setup’, ‘custom_setup’,15); [/code]

This function hooks to Genesis setup which is the first parameter. Next parameter is the name of the function we will be using to execute our custom Genesis child theme functionalities. Finally, the third parameter is the value which ensures that our function file executes after the parent theme so it may override our custom functionality.

Text domain in WordPress is an identifier that helps WordPress to identify between all loaded translations and for that, we will add another function to our functions.php file as follows:

[code style="php"] // Load child theme textdomain.
load_child_theme_textdomain( ‘custom’ ); [/code]

For our Genesis child theme setup function, we will initialize a custom wrapper function.

[code style=”php”] function custom_setup(){} [/code]

Scroll to Top