Skip to content

Instantly share code, notes, and snippets.

@ejke
Created March 7, 2018 11:25
Show Gist options
  • Save ejke/88dcd23a5d951d60fd7dc34bbe9f7d6c to your computer and use it in GitHub Desktop.
Save ejke/88dcd23a5d951d60fd7dc34bbe9f7d6c to your computer and use it in GitHub Desktop.
wp connect child parent css
<?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