function.php Archives - MYSTERY THEMES Free & Premium WordPress Themes Mon, 29 Apr 2024 11:33:47 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.4 https://mysterythemes.com/wp-content/uploads/2016/02/mt-fav.png function.php Archives - MYSTERY THEMES 32 32 103277301 How to Create WordPress Child Theme Step by Step Tutorial https://mysterythemes.com/blog/create-wordpress-child-theme-tutorial/ https://mysterythemes.com/blog/create-wordpress-child-theme-tutorial/#comments Tue, 07 May 2019 10:10:04 +0000 https://mysterythemes.com/?p=9958 Do you want to create a WordPress child theme step by step? WordPress lets you create a child theme that has the ability to inherit all the characteristics of the parent theme. In this article, we’ll show you how to create a WordPress child theme step-by-step in two different ways: What is a WordPress child […]

The post How to Create WordPress Child Theme Step by Step Tutorial appeared first on MYSTERY THEMES.

]]>
Do you want to create a WordPress child theme step by step? WordPress lets you create a child theme that has the ability to inherit all the characteristics of the parent theme.

In this article, we’ll show you how to create a WordPress child theme step-by-step in two different ways:

  • Creating a WordPress child theme manually
  • Creating a WordPress child theme using the plugin

What is a WordPress child theme?

The WordPress Child Theme is a WordPress theme that acquires all the functionality and features of the parent theme. It’s easy to change the child theme without affecting the parent theme; however, if you make any changes to the parent theme, it will automatically make changes to the child theme itself.

Requirements to create a WordPress child theme:

Basic knowledge of HTML and CSS helps you make changes to your own concept. It will be better if you have some basic PHP knowledge, which surely helps too.

Creating a WordPress Child Theme Manually

Before creating a child theme, ensure the parent theme is present on the Appearance >> Themes pages.

  • Navigate to “wp-content/themes/” in the WordPress installation directory and create a folder named, e.g., newsportal-child.
  • Next, open the text editor available on your device and paste this code:
/*
Theme Name: News Portal Child
Theme URI: https://mysterythemes.com/wp-themes/news-portal-child/
Description: News Portal Child Theme
Author: Mystery Themes
Author URI: https://mysterythemes.com/
Template: News Portal
Version: 1.0
*/

Once pasted, save the file named style.css in the just created “newsportal-child” folder.

  • Create a function.php file in the same folder and paste this code:
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
   wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
  • Once you have pasted the code, zip the folder and go to Appearance >> Themes >> Add New to upload the file.
  • When the theme is successfully installed, click on the Activate and this is how it looks like:
Activate WordPress child theme

If you don’t want to create it manually, then you can create a WordPress child theme using the plugin.

Creating a WordPress Child Theme using Plugin

Child Theme Configurator – WordPress plugin WordPress.org-min
  • Download the Child Theme Configurator plugin.
  • Log in to the WordPress admin area of your site.
  • Go to Plugins >> Add New.
  • Click on Upload Plugin, then click the Activate button to activate the plugin on your site.
  • Now go to Tools > Child Themes. The “Child Theme Configurator” plugin main screen will appear.
  • Select the parent theme, fill in all the options and click on the Create New Child theme.
  • You will get a notice at the top of the page saying the child theme has been generated successfully. Click on the Preview Your Child theme link.
  • Finally, click on the Activate & Publish button.

In this way, you can easily create a child WordPress theme using a plugin. For more details, you can see the Child Theme Configurator installation.

Customize your WordPress Child Theme

Once you’ve created the child theme, you can start to customize the WordPress child theme. Through this article, we will show you how to create and customize a WordPress child theme:

  • Customize the design in Child Theme
  • Edit the template file of single.php in WordPress Child Theme

Customize the design in Child Theme

To customize the design, you need to edit the style.css file of the child theme that is located in the child theme folder. Example: Add the below code to the child theme’s style.css if you want to change the color and font:


a{
color: #DAE3FA; 
font: medium; 
text-decoration: none;
}

By doing this, the Child theme’s style.css rule for “a” overrides the style.css of the parent theme. Similarly, if you want to change the layout of posts and pages, you can enable overriding the default layout by creating your own layout in the template files.

Edit the templates file of single.php in WordPress Child Theme

You can easily edit the template file, such as single.php, in the Child theme by following these steps:

  • Simply copy the parent theme file from the folder.
  • Paste it at the corresponding location in the child theme.
  • Open the file in the available text editor and edit it.

In this way, you can easily overwrite any template of the parent theme from the child theme.

Conclusion

Hence, this is how we can easily build a WordPress child theme, step by step. If you like this article, give us your feedback, and don’t forget to subscribe to us and also follow us on Facebook and Twitter.

You might also like to read our other informative articles:

The post How to Create WordPress Child Theme Step by Step Tutorial appeared first on MYSTERY THEMES.

]]>
https://mysterythemes.com/blog/create-wordpress-child-theme-tutorial/feed/ 6 9958