Support » Themes and Templates » Why won't my theme pick up its child style.css?

Viewing 15 replies - 1 through 15 (of 23 total)
  • What Theme are you using as the Parent/Template Theme?

    It’s Absolum – I can’t find a great deal of help on it when searching around so I wonder if I’ve chosen a duff theme for customising?!

    You’ll have to add a functions.php file to your Child Theme. Absolum doesn’t hard-code the stylesheet link into the document header, but rather enqueues it.

    You have two options:

    If you’re simply adding some style changes to the default (i.e. if you’re using @import in your child Theme’s style.css:

    1) remove the @import call,
    2) Add the following to functions.php

    function absolumchild_enqueue_style() {
         wp_enqueue_style( 'absolumchild', get_stylesheet_uri() );
    }
    add_action( 'wp_print_scripts', 'absolumchild_enqueue_style', 11 );

    Alternately, if you’re completely overriding the Parent Theme’s style (i.e. if you have all of the Parent Theme’s style definitions in your Child Theme’s style.css):

    1) Add the following to functions.php

    function absolumchild_enqueue_style() {
         wp_dequeue_style( 'absolum_css' );
         wp_enqueue_style( 'absolumchild', get_stylesheet_uri() );
    }
    add_action( 'init', 'absolumchild_enqueue_style', 11 );

    I added it to the bottom of functions.php in the child directory and got:

    function absolumchild_enqueue_style() { wp_dequeue_style( ‘absolum_css’ ); wp_enqueue_style( ‘absolumchild’, get_stylesheet_uri() ); } add_action( ‘init’, ‘absolumchild_enqueue_style’, 11 );
    Fatal error: Cannot redeclare absolum_theme_options_init() (previously declared in /www/sites/fa9/78e/www.westeuston.org/web/wp-content/themes/absolum-child/functions.php:8) in /www/sites/fa9/78e/www.westeuston.org/web/wp-content/themes/absolum/functions.php on line 10

    agh!!!!

    What is on line 8 of your child Theme functions.php file? That error is entirely unrelated to what we’ve done here.

    Here’s 7 8 and 9:

    function absolum_theme_options_init() {
    register_setting( ‘absolum_options’, ‘absolum’, ‘absolum_theme_options_validate’ );
    wp_register_style(‘mycss’, WP_CONTENT_URL . ‘/themes/absolum/css/theme-options.css’);

    This is your problem:
    function absolum_theme_options_init()

    You can’t use that function name; it’s already declared (used) by your Parent Theme. You need to use a unique function name.

    Also, why do you have this function declaration in your child Theme’s functions.php file to begin with? It’s declared in the Parent Theme, so you shouldn’t need to re-declare it.

    Apols, I know nothing…. trying to run before I can walk….

    Can you post a pastebin with your entire child Theme functions.php file?

    Now I’ve really messed it up. Deleted everything from child function.php to leave the following, thinking that as everything else appears in parent’s function.php maybe that’s all I need. Now it’s still only using the parent style.css!

    <?php
    function absolumchild_enqueue_style() {
    wp_dequeue_style( ‘absolum_css’ );
    wp_enqueue_style( ‘absolumchild’, get_stylesheet_uri() );
    }

    ?>

    That’s not the entire code block. Nothing will happen without the accompanying add_action():

    function absolumchild_enqueue_style() {
         wp_dequeue_style( 'absolum_css' );
         wp_enqueue_style( 'absolumchild', get_stylesheet_uri() );
    }
    add_action( 'init', 'absolumchild_enqueue_style', 11 );

    p.s. please place code within backticks, or <code> tags.

    That’s it!!!! It’s using my child style.css!!! Thankyou sooo much 🙂

    Glad to help. 🙂

    Fatal error: Cannot redeclare mytheme_add_admin() (previously declared in /home/zebrastr/public_html/wp-content/themes/Maximo/functions.php:198) in /home/zebrastr/public_html/wp-content/themes/Maximo/functions.php on line 583

    my site is not open…

    how to solve it

    Look on line 198 of Maximo/functions.php.

    Now look on line 583 of Maximo/functions.php.

    You’re declaaring (i.e. defining) the same function, mytheme_add_admin(), in both places. You can’t do that in PHP. Pick one fucntion declaration or the other, or else combine the code (if applicable).

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Why won't my theme pick up its child style.css?’ is closed to new replies.