Created
March 7, 2018 11:25
-
-
Save ejke/88dcd23a5d951d60fd7dc34bbe9f7d6c to your computer and use it in GitHub Desktop.
wp connect child parent css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function use_parent_theme_stylesheet() { | |
// Use the parent theme's stylesheet | |
return get_template_directory_uri() . '/style.css'; | |
} | |
function my_theme_styles() { | |
$themeVersion = wp_get_theme()->get('Version'); | |
// Enqueue our style.css with our own version | |
wp_enqueue_style('child-theme-style', get_stylesheet_directory_uri() . '/style.css', | |
array(), $themeVersion); | |
} | |
// 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', 'my_theme_styles', 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment