WordPress knowledge sharing

How to create WordPress subthemes manually

WordPress subthemes provide users with more freedom to make changes to WordPress themes without being affected by program updates. Manually create WordPress subthemes The minimum requirements for are the following two files: style.css and functions.php.

For novices, it is difficult to create sub themes manually, so it is easier to create sub themes with one click of plug-ins. Please move to Child Theme Wizard and Child Theme Configurator see.

1、 The style.css stores the CSS code of the WordPress theme. If you want to add a custom css style later, add it to style.css.

Use Dreamweaver or similar software to create a file named style.css and add code:

/*
Theme Name: Twenty Twenty-One Child
Theme URI: https://www.vpsss.net
Description: Twenty Twenty-One Child is a child theme of Twenty Twenty-One, created by vpsss.net team
Author: vpsss Team
Author URI: https://www.vpsss.net/
Template: Twenty Twenty-One
Version: 1.0.0
Text Domain: Twenty Twenty-One Child
License: GNU General Public License v3 or later.
License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/

You need to replace the content after the colon with your actual information:

  • Theme Name – Sub theme name
  • Theme URI – Theme and document website
  • Description – Subject description
  • Author – Name of the subject author
  • Author URI – Subject author website
  • Template – The name of the parent theme folder (the same as the parent theme name in the/wp content/themes folder). This line is very important because sub topics use this line to identify the parent topic and work.
  • Version – Subtopic version number.
  • Text Domain – For international use, add "- child" at the end of the template name.
  • License – Leave the default.
  • License URI – Leave the default.

Only the Template line is the most important, and other contents are not important. Just make sure you enter the folder name of the template parent theme correctly.

2、 functions.php

Create a functions.php file for the subtheme. Create a blank php file named functions.php, and add the following code:

<? php

/* Function to enqueue stylesheet from parent theme */

function child_enqueue__parent_scripts() {

wp_enqueue_style( ‘parent’, get_template_directory_uri().’/ style.css’ );

}

add_action( ‘wp_enqueue_scripts’, ‘child_enqueue__parent_scripts’);

3. Upload files to WordPress theme folder

 Upload files to WordPress theme folder

Upload the new theme of style.css file and functions.php file to WordPress website.

Use FTP software (pagoda panel file function or virtual host cPanel panel) to connect to the host, locate the site theme directory/wp content/themes/, and create a new folder for the sub theme.

For example, the parent theme folder name is Twenty Twenty One, and the child theme folder name is Twenty Twenty One Child. Then upload the style.css and functions.php files to the folder.

Next, go to WordPress Appearance>Themes, enable sub themes like other WordPress themes, and start setting themes and building websites.

Like( zero )
Article name: How to Create WordPress Subthemes Manually
Article link: https://www.vpsss.net/26148.html
Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself.
The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.