Creating A Child Theme In WordPress

Creating A Child Theme In WordPress

Child Themes

A child theme inherits features from the parent theme and provides a safe way to customize the parent theme without loosing modifications when updating the parent theme.

How To Create a Child Theme using the Twentyfourteen Theme

  • FTP into your WordPress website.
  • Create a new directory in the ‘wp-content/theme’ folder and name it ‘twentyfourteen-child’.
  • Place a ‘style.css’ inside the ‘twentyfourteen-child’ directory with the following.
/*
 Theme Name:   Twenty Fourteen Child
 Theme URI:    http://you.com/
 Description:  Twenty Fourteen Child Theme
 Author:       John Doe
 Author URI:   http://you.com
 Template:     twentyfourteen
 Version:      1.0.0
 Text Domain:  twenty-fourteen-child
*/

/******************************************/
/* Child Theme Customization Starts Here */
/******************************************/
  • Next, place a ‘functions.php’ inside the directory ‘twentyfourteen-child’ with the following code to queue the stylesheet.
<php
// Enqueues child theme stylesheet
function twenty_custom_enqueue_child_theme_styles() {
	wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'twenty_custom_enqueue_child_theme_styles', 11 );
?>
  • Now, activate the child theme. From the dashboard, go to ‘Appearance’, ‘Themes’, hover above ‘twentyfourteen-child’ theme, and click’Activate’.

The child theme’s, ‘style.css’ will now override the parent theme’s stylesheet.

Template Files

To override parent theme files, copy the parent file into the child theme directory and modify accordingly.

Tagged