Skip to content

Instantly share code, notes, and snippets.

@maddisondesigns
Created August 2, 2016 05:59
Show Gist options
  • Save maddisondesigns/43ad1f273135a45823f0075f139ef746 to your computer and use it in GitHub Desktop.
Save maddisondesigns/43ad1f273135a45823f0075f139ef746 to your computer and use it in GitHub Desktop.
WordPress Child Theme Example
<?php
function mytheme_scripts_styles() {
// Enqueue the parent theme stylesheet
wp_enqueue_style( 'parent-style', trailingslashit( get_template_directory_uri() ) . 'style.css' );
// Ensure the default WordPress stylesheet is enqueued after the parent stylesheet
wp_enqueue_style( 'style', get_stylesheet_uri(), array( 'parent-style' ) );
}
add_action( 'wp_enqueue_scripts', 'mytheme_scripts_styles' );
/*
Theme Name: Your Child Theme Name
Theme URI: http://example.com/my-awesome-child-theme
Description: A description for your Child Theme
Author: Your name
Author URI: http://example.com
Template: parent-theme-folder-name
Version: 1.0.0
*/
@maddisondesigns
Copy link
Author

maddisondesigns commented Aug 24, 2016

Pro Tip:
When adding the above code to your style.css file, don't forget to update the Template name.
Although not technically needed for it to work, it’s a good idea to also create a .png image (screenshot.png) to display a screenshot on the Themes page in the Dashboard. The image should be 1200 x 900px.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment