• Resolved ellacopter

    (@ellacopter)


    It’s my first time working from a child-theme so apologies in advance if I’m being slow on the uptake!

    My child theme isn’t overriding my parent theme.

    Here is my functions.php

    <?php
    add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
    function my_theme_enqueue_styles() {
    wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );

    }

    function load_fonts() {
    wp_register_style(‘et-googleFonts’, ‘https://fonts.googleapis.com/css?family=Open+Sans&#8217;);
    wp_enqueue_style( ‘et-googleFonts’);
    }
    add_action(‘wp_print_styles’, ‘load_fonts’);

    And here is my style.css

    /*
    Theme Name: Twenty Eleven Child
    Theme URI: https://www.audioplus.co.uk
    Description: Twenty Eleven Child Theme
    Author: Ella
    Author URI: https://www.ellacopter.com
    Template: twentyeleven
    Version: 1.0.0
    License: GNU General Public License v2 or later
    License URI: https://www.gnu.org/licenses/gpl-2.0.html
    Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
    Text Domain: twenty-eleven-child
    */

    /////*Site Title*//////

    h1#site-title img{
    width:350px;
    height:178px;
    }

    h1#site-title {
    margin-right: 270px;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0.0em;
    }

    h2#site-description {
    margin-bottom: 0.0em;
    }

    /////*Font*//////
    #body {
    font-family: ‘Open Sans’ , sans-serif;
    font-size: 14px;
    color: #000000;

    }

    /////*Navigation*//////
    #access {
    background: #e2e2e2;
    border-bottom: 1px solid #000000;

    }

    Any help would be great. Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You’re not enqeueing the child theme. Instead of:

    function my_theme_enqueue_styles() {
    wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
    

    it should be:

    function my_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( 'twentyeleven' )
    )
    

    By adding the twentyeleven handle to your child theme enqueue function, we can ensure that it loads after your parent theme loads.

    Moderator t-p

    (@t-p)

    Codex on creating a child theme: child theme

    Thread Starter ellacopter

    (@ellacopter)

    Thank you!

    I’m now getting this error.

    Parse error: syntax error, unexpected ‘wp_enqueue_style’ (T_STRING) in /homepages/34/d262023013/htdocs/audiopluscouk/wordpress/wp-content/themes/twentyeleven-child/functions.php on line 5

    This is my functions.php

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_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( 'twentyeleven') );
    }
    
    function load_fonts() {
                wp_register_style('et-googleFonts', 'https://fonts.googleapis.com/css?family=Open+Sans');
                wp_enqueue_style( 'et-googleFonts');
            }
        add_action('wp_print_styles', 'load_fonts');
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Try putting a semi-colon on the end of line 4.

    Thread Starter ellacopter

    (@ellacopter)

    Thanks Andrew. That got rid of the error perfectly, but the changes in my child theme style.css file still isn’t showing.

    Thread Starter ellacopter

    (@ellacopter)

    I’m still struggling with this. Can anybody help?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Edit: Oh sorry misread.

    Your Child Theme style.css file is broken because of this line:

    
    
    /////*Site Title*//////
    

    That is not a CSS comment. This is a CSS comment:

    
    /*Site Title*/
    

    A browser will not read CSS beyond a syntax error like the one above.

    Thread Starter ellacopter

    (@ellacopter)

    Thank you so much, Andrew!

    This is all such a learning experience – I’ll get there in the end!

    Thank you again!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Child theme not overriding parent theme’ is closed to new replies.