Not 100% sure if this question is legit for stack, but it doesn’t belong in Meta and it does involve some code, and I don’t think its subjective – should have an answer…
I have a new wordpress site using The7 theme and I have, of course, created a child theme using “One Click Child Theme” plugin.
All works fine, I put a little custom css in there to adjust the navigation and it adjusts, but when I look at the Inspector in chrome, I see my custom css listed twice! Does anyone know why this is? I don’t have any extra import
statements in my child stylesheet, and even if I did, this code isn’t in the parent stylesheet anyhow. Is the child stylesheet being loaded twice?
I know quite a bit of web code, but fairly new to using WordPress. Is this normal behavior?
This is my entire child stylesheet:
/*
Theme Name: the7 Child
Description:
Author: chris@sqlfocus.com
Template: dt-the7
(optional values you can add: Theme URI, Author URI, Version, License, License URI, Tags, Text Domain)
*/
ul.main-nav {
padding-left: 100px;
padding-right: 100px;
-webkit-padding-start: 100px;
-webkit-padding-end: 100px;
}
functions.php:
<?php
//
// Recommended way to include parent theme styles.
// (Please see http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme)
//
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style')
);
}
//
// Your code goes below
//
I had the exact same problem with an Enfold theme and I’ve seen it before with other themes.
I studied the HTML output for a page and discovered the theme was auto-including my stylesheet. This is unexpected and therefore undesirable because unpredictability is undesirable — not all themes do this.
The fix? Kinda funny… but I just…
removed my own reference from functions.php and let the parent theme auto-include it for me
Sad but true…