Required (child) Theme Files
Check if your child theme has a
- style.css
- functions.php
- screenshot.png (optional, but will help you differentiate)
Recommended basic functions.php
for a child theme
<?php
/**
* Example child theme Remzi Cavdar
*
* @link https://developer.wordpress.org/themes/advanced-topics/child-themes/
*
*
*/
function use_parent_theme_stylesheet() {
// Use the parent theme's stylesheet
return get_template_directory_uri() . '/style.css';
}
function child_theme_branding() {
// Uncomment this if you want versioning in your child theme stylesheet
// $themeVersion = wp_get_theme()->get('Version');
// Enqueue our style.css with our own version
wp_enqueue_style( 'child-theme-branding', get_stylesheet_directory_uri() . '/style.css', array(), null );
}
// Filter get_stylesheet_uri() to return the parent theme's stylesheet
add_filter( 'stylesheet_uri', 'use_parent_theme_stylesheet' );
// Enqueue this theme's scripts and styles (after parent theme)
add_action( 'wp_enqueue_scripts', 'child_theme_branding', PHP_INT_MAX );