Important: Do not edit parent theme files under any circumstances. If someone tells you to edit your parent theme files or edit them on your behalf, you should question their abilities to support you further.
Note: There are times when you don’t need a child theme, and all you need is to add code snippets via a plugin. This guide covers that as well.
When to Install the Child Theme
A WordPress child theme is needed when you want to customize or modify the parent theme without losing any changes you make when the parent theme is updated. Below are some scenarios where a WordPress child theme is recommended:
- Parent Theme Customization: If you want to customize the theme by changing its design or functionality, a child theme allows you to add your own custom code and styles that will override the parent theme without affecting the original code.
- Theme Updates: If you make changes to a WordPress parent theme directly, those changes will be lost when the theme is updated. Using a child theme lets you keep your customizations intact even when the parent theme is updated.
- Creating New WordPress Themes: If you want to create a new WordPress theme based on an existing theme, you can use a child theme as a starting point. This way, you can modify the existing theme without starting from scratch.
Just to give you one example of where I needed to use the child theme, in the How to Fully Customize the MyListing Dashboard With Elementor guide, where I had to add files for the new WooCommerce endpoints.
How to Install the Child Theme
- Make a backup of your website, even though this is a low-risk task.
- Download the MyListing Child Theme. (Note: The child theme is also available if you were to perform a full download of the MyListing theme from Themeforest, but I provide the same file for easier access as a courtesy.).
- WordPress Dashboard > Appearance > Themes
- Click the ‘Add New Theme’ box.
- Click the ‘Upload Theme’ button at the top of the page.
- Click the ‘Choose File’ button and browse to the file you downloaded in Step 1.
- Click the ‘Install Now” button.
- Click on the newly-installed Child Theme box and click ‘Activate.’
Alternatives to Using the MyListing Child Theme
If you don’t need to add files to the theme, you can add custom code to your website without editing files directly.
Using a Code Snippet Plugin Like WPCodeBox
WPCodebox is hands down my recommended solution, and you can find out why within the Easily Manage Code Snippets for Your MyListing Website With WPCodeBox guide.
Theme Tools > Theme Options > Custom Code
This area of the theme settings allows you to add custom code, whether it’s CSS, JavaScript, or Raw Code. I do not recommend adding code here for the reasons outlined below.
- It will likely hurt your website’s performance. Why? Unlike WPCodeBox, in which you can tell when and where code should run, any code you add to the Custom Code area of MyListing will load/run in places where it doesn’t need to.
- You risk breaking your website. Unlike WPCodeBox, there is no way to tell if the code you are adding has issues with syntax.
- You’ll miss out on learning a bit about coding and best practices. Unlike WPCodeBox, this area for adding code does not provide an auto-complete feature to assist you with the code that should be entered, nor does it provide you with indicators that you’re not following best practices.
