Support » Themes and Templates » Parent Theme Over Riding Child Theme Every Time

  • Resolved Elymnesis

    (@elymnesis)


    I’m new to WordPress, and I’m having trouble with child themes. I’m eagerly trying to learn the system, and the problem I’m consistently having is that none of my child themes override my parent themes. They are displayed as crossed out in the developer tools.

    The only thing I’m trying to change right now is the color of the header. What am I doing wrong?

    Here is my site:

    Help would be very deeply appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Your theme is calling an additional stylesheet named black.css after your child theme’s main stylesheet. The styles in black.css are overriding your color rules in your child theme’s stylesheet. A quick fix would be to use !important in your child theme’s stylesheet.

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    You are doing nothing wrong, actually. Part of the reason that your child theme isn’t overriding the color is, as stephen stated, the second stylesheet is being loaded.

    There are several ways of going about this and they all depend on how comfortable you are with code and editing files.

    == Version one ==
    1. Create a header.php file and remove the line:

    <link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="screen" />

    2. Create a functions.php file and add:

    add_action( 'wp_enqueue_scripts', 'child_style' );
    function child_style(){
        wp_enqueue_style( 'parent', PC_THEME_ROOT_URI . '/style.css' );
        wp_enqueue_style( 'child', get_stylesheet_uri(), array( 'parent', 'color-scheme-stylesheet' ) );
    }

    == Version Two ==
    1. Create a header.php file and move the line:

    <link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>" type="text/css" media="screen" />

    after <?php wp_head(); ?>

    == Version three ==
    1. use !important on all the rules that are being a pain in the tushy.

    Thread Starter Elymnesis

    (@elymnesis)

    Thank you very much for the help! Jose, I used both of your first two solutions and both worked perfectly. I’m going to continue to use the first version, because I’m guessing it’s the most standard, or you wouldn’t have mentioned it first. (I have experience in CSS and HTML, but PHP is new to me.)

    I also didn’t know about !important. What a great command. This should help me very much.

    Thank you thank you thank you!

    Moderator Jose Castaneda

    (@jcastaneda)

    THEME COFFEE MONKEY

    Happy to help.

    Yes, the first is sort of a standard when it comes to stylesheets and scripts and is standard theme review guidelines. Part of that reason is so that if any child themes or plugins rely on certain scripts/styles won’t misbehave. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Parent Theme Over Riding Child Theme Every Time’ is closed to new replies.