• Resolved ryanmacmorris

    (@ryanmacmorris)


    I tried to use a child theme to customize the css of some portions but it seems that it is always overridden by the parent theme. I used the child theme plugin to create the child theme and have successfully changed things through the functions.php and the front-page template but am unable to do an changes via css. Is there a way I should be calling the stylesheets in other than with the default child theme php? My site is https://www.ryanmacmorris.com and if you look at the source you can see that the css are getting called in an odd order it seems to me.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The problem is that you have a syntax error in your child theme’s style.css file:

    }
    
    .blog .hentry a.button {
       background-color: #bb00bb;
    }

    Remove the stray right brace at the very top and your Read More buttons will turn purple.

    And yes, there’s something else wrong because your child theme’s stylesheet is being linked in twice. Not sure if it was caused by the plugin, but how is your functions.php file enqueuing your stylesheets? You may not need to enqueue the child theme’s style.css file since it’s already being included.

    Thread Starter ryanmacmorris

    (@ryanmacmorris)

    This is my entire functions.php file and I believe the default functions.php of the child theme plugin.

    <?php
    //
    // Recommended way to include parent theme styles.
    //  (Please see https://codex.www.ads-software.com/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
    //

    Since it looks like the parent theme is already enqueing the child theme’s stylesheet, remove the enqueing of it in your child theme’s function.php file, so it looks like this (i.e., you only need to enqeue the parent theme’s stylesheet):

    <?php
    //
    // Recommended way to include parent theme styles.
    //  (Please see https://codex.www.ads-software.com/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' );
    }
    //
    // Your code goes below
    //

    And don’t forget to correct the syntax error in your child theme’s style.css file.

    Thread Starter ryanmacmorris

    (@ryanmacmorris)

    That did the trick, thanks a bunch for the help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Child theme problems’ is closed to new replies.