Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Child Theme Not Prioritising Over Parent Theme

Discussion in 'Misc WordPress Requests' started by willowen100, Nov 2, 2017.

  1. willowen100

    Guest

    Child Theme Not Prioritising Over Parent Theme, by willowen100

    Hi

    I’ve been making tweaks to a child theme taken from a premium theme I purchased. Originally I was using the additional CSS panel under customise but now I would like to migrate the CSS code over to my child theme’s style.css. However, my code only seems to work if I use the !important flag.

    I’m convinced my functions.php or style.css files have been setup correctly after reading the official documentation and looking at lots of guides and I have printed the functions.php and style.css files below. The child theme is in a folder called sydney-pro-ii-child; identical to the original sydney pro theme folder just with ‘child’ on the end.

    [​IMG]

    functions.php


    <?php
    function my_theme_enqueue_styles() {

    $parent_style = 'sydney-pro-ii-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.

    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 ),
    wp_get_theme()->get('Version')
    );
    }
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    ?>

    style.css

    /*
    Theme Name: Sydney Pro Child
    Theme URI: http://athemes.com/theme/sydney
    Author: aThemes
    Author URI: http://athemes.com
    Template: sydney-pro-ii
    Version: 1.0
    License: GNU General Public License v2 or later
    License URI: http://www.gnu.org/licenses/gpl-2.0.html
    Text Domain: sydney-pro-ii-child
    */

    The code below is taken from the style.css in the parent theme and I have added it to my child’s style.css. This changes the social icons down in the footer.

    .social-menu-widget a:hover {
    color: blue;
    }
    .social-menu-widget a {
    color: yellow;
    }

    However, it doesn’t work unless I set the !important flag.

    .social-menu-widget a:hover {
    color: blue !important;
    }
    .social-menu-widget a {
    color: yellow !important;
    }

    I hope someone can shed some light on this as it will be much appreciated.

    Will

    Child Theme Not Prioritising Over Parent Theme
     
    #1

Share This Page

Web Hosting