• NEWB ALERT – Been stuck on this for a few days.

    I made a child theme for Matheson and pretty certain I did everything correctly according to https://codex.wordpress.org/Child_Themes. It’s activated in WP but none of the CSS I apply to the child theme will work. I just want to tweak a few things in the design – nothing major.

    Here is the code in my child theme’s style.css :

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    /*
    Theme Name:	Matheson Child
    Theme URI:	http://www.andysells.net/public_html/wp-content/themes/matheson-child
    Description:	A basic child theme for Matheson
    Author:		c.bavota
    Author URI:	http://themes.bavotasan.com/
    Template:	matheson
    Version:	0.1
    */
    
    @import "(../matheson/style.css)";
    
    body {
    background-color:black;
    }
    .marketing h2{
    color:red;
    }

    The https://codex.wordpress.org/Child_Themes page indicated to create a functions.php file in my child theme so I did that to. Here is the code for that:

    <?php
    function theme_enqueue_styles() {
    
        $parent_style = 'parent-style';
    
        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 )
        );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    ?>

    ———

    I added the @import “(../matheson/style.css)”; line even though the directions said it wasn’t recommended. It doesn’t seem to make a difference either way. It still doesn’t register any CSS code that I add to the child theme. OK what am I doing wrong? thanks.

Viewing 15 replies - 1 through 15 (of 55 total)
  • First…
    What is the name of your parent theme? (the name on its folder – all in small case letters)
    What is the name of your child theme? (the name on its folder – all in small case letters)

    Thread Starter peugeotenthusiast

    (@peugeotenthusiast)

    parent theme is ‘matheson’

    child theme is ‘matheson-child’

    Thread Starter peugeotenthusiast

    (@peugeotenthusiast)

    hmmm…

    Remove @import "(../matheson/style.css)"; from your child theme’s css (style.css).

    Is there any other code (besides <?php) in the child theme’s functions.php file?
    If yes, post back here before doing anything.
    If not, proceed…

    If there is no other code in the functions.php file, paste the code below, exactly as it is, into your child theme’s functions.php file.
    No closing tag – ?> – and no space underneath the last line of code.

    If there is a <?php already at the top of the functions.php file – delete it. There only needs to be one <?php

    <?php
    
    function mathesonchild_enqueue_styles() {
    
        $parent_style = 'matheson';
    
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'matheson-child',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style )
        );
    }
    add_action( 'wp_enqueue_scripts', 'mathesonchild_enqueue_styles' );

    Let me know if it works.

    Thread Starter peugeotenthusiast

    (@peugeotenthusiast)

    Thanks for your help. I did exactly what you said. It didn’t seem to make any difference.

    There is no space underneath the code?
    Clear your browser’s cache and refresh your browser.

    Thread Starter peugeotenthusiast

    (@peugeotenthusiast)

    sure thing. It didn’t seem to make a difference. :/

    Thread Starter peugeotenthusiast

    (@peugeotenthusiast)

    no space underneath the .php code. I deleted the old code and pasted exactly what you typed.

    The Child Theme is loading twice…

    <link rel='stylesheet' id='matheson-css'  href='http://andysells.net/wp-content/themes/matheson/style.css?ver=4.4.1' type='text/css' media='all' />
    <link rel='stylesheet' id='matheson-child-css'  href='http://andysells.net/wp-content/themes/matheson-child/style.css?ver=4.4.1' type='text/css' media='all' />
    <link rel='stylesheet' id='theme_stylesheet-css'  href='http://andysells.net/wp-content/themes/matheson-child/style.css?ver=4.4.1' type='text/css' media='all' />

    …do you have some plugin for creating a child theme running?

    This one here…
    <link rel='stylesheet' id='theme_stylesheet-css' href='http://andysells.net/wp-content/themes/matheson-child/style.css?ver=4.4.1' type='text/css' media='all' />
    …is not the standard loading function.

    Thread Starter peugeotenthusiast

    (@peugeotenthusiast)

    Do you mean a plugin in WP? or my browser? No, not to my knowledge. I installed Firebug yesterday. I haven’t installed any plugins in WP at all.

    Something somewhere on your site is loading an exact copy of your child theme. It is either part of the theme doing it or a plugin, because of the way this is written – “theme_stylesheet-css” instead of “matheson-child-css” – but you say you have no plugins running.

    This is the links to my parent and child css on my development site…

    <link rel='stylesheet' id='neotechnomadbase-css'  href='http://neotechnomadbase.neotechnomad.ca/wp-content/themes/neotechnomadbase/style.css?ver=4.4.1' type='text/css' media='all' />
    <link rel='stylesheet' id='neotechnomadchild-css'  href='http://neotechnomadbase.neotechnomad.ca/wp-content/themes/neotechnomadchild/style.css?ver=4.4.1' type='text/css' media='all' />

    …this is how it is supposed to look like.

    Firebug wouldn’t do anything.

    Thread Starter peugeotenthusiast

    (@peugeotenthusiast)

    hmm.. it looks like Jetpack was activated. Should I de-activate it? Should I re-install the child theme and start from the scratch with the code you provided for my child’s functions.php?

    No, just deactivate Jet-Pack and any other plugin that may be running and then see if everything is working.
    Let me know when the plugins are deactivated and I will check the source code.

    Thread Starter peugeotenthusiast

    (@peugeotenthusiast)

    I deactivated it. That was the only thing running. Thanks.

Viewing 15 replies - 1 through 15 (of 55 total)
  • The topic ‘child theme's style.css won't cooperate’ is closed to new replies.