How to Create a Child Theme in WordPress and Deleted Unnecessary Scripts and Code

Опубликовано: 24 Ноябрь 2024
на канале: Ezoic
2,216
40

In this episode, Whitney shows you how to easily create WordPress child theme that you can then alter with PHP to pull out unnecessary woocommerce and jetpack script and code.

First, you’ll want to find the Child Theme Configurator plugin and install it on your website.

After the plugin is installed, navigate to Tools and then Child Themes. Select ‘Create a new Child Theme.’ Then, you’ll select a parent theme. Then click Analyze.

After it loads, name your child theme. Also, make sure Where to save is set as primary and Use the WordPress style queue is selected.

Here, you can click to edit child theme attributes and rename anything you like.

When you’re ready, click Create Child Theme.

Now, when you go to Appearance and then Themes, you should have your child theme there.

If you would like to edit your child theme, you can click Theme Editor. Here, choose your child theme and click Select.

Now, go to Theme Functions. We are going to add some PHP that will strip out unnecessary woocommerce.

Woocommerce causes issues because all of the block styles for Guttenberg load on every page, which is not ideal because it slows down the site speed. PHP allows you to filter woocommerce from pages that do not store pages and remove all of the different blocks and styles that don’t need to be loaded.

After the PHP is inserted into Theme Functions, click Update File. It should say it edited it successfully.

You can also do this to remove front-end jetpack CSS scripts for sh are counting and other front-end CSS that most sites don’t use. Simply add this PHP to your Theme Functions file like we did the woocommerce PHP, and click Update File.

Now, you can go back to your themes and activate the child theme.
PHP: https://docs.google.com/document/d/1t...