Support » Themes and Templates » Theme child and new style.css

  • Hi friends,
    I’ve created a theme child as suggested here:https://codex.wordpress.org/it:Temi_Child

    and I’ve not created a stile.css containing the @import function, but put this code into the new one functions.php:

    <?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }

    And now for example if I want to assign a style to my new widget, I can adding code into the new style.css into the template_child and all work fine.

    But happen this too:

    if I want to change css attributes to the original template, adding css code to the new style.css made no change. I need change again the original style sheet

    where have I gone wrong? 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi danjde,
    Using @import is not as bad as it is written. I use it all the time without any trouble.
    Anyway,
    As you described your process you added just enqueue script action and did not included enqueued enqueue style action

    read again this

    I think you missed this code to add to your child’s function.php file

    <?php
    function my_theme_enqueue_styles() {
    
        $parent_style = 'parent-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' );
    ?>

    Hope Im helpful.
    Cheers
    @tahoerock

    Hi Tahoe and thanks very much for your help!!

    I’ve put as you suggest also the last piece of code as below:

    ?php
    
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
    function enqueue_parent_theme_style() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }
    ?>
    <?php
    function my_theme_enqueue_styles() {
    
        $parent_style = 'parent-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' );
    ?>
    <?php

    But it has no make changes:
    only if I edit the originary style.css can obtain any result.

    Could be an issue specific of my theme? I’m using a “non standard” (aka commercial) wordpress template.
    Or I should customize this code?

    Many thanks again!

    • This reply was modified 3 years, 1 month ago by danjde.
    Moderator stephencottontail

    (@stephencottontail)

    If you’re using a commercial theme, there’s a chance that it loads its stylesheets in a goofy way, and since no one here has access to your theme to check, you’re probably better off asking your theme’s vendors for support. After all, that’s part of what you paid for.

    Hi Dandje,
    YES, I have to aggre with Stephen.
    I was gouing to suggest same. We cannot check it here.
    It is paid and they should provide apropriate support.
    Wishing you the best
    Cheers
    @tahoerock

    Yes @tahoerock and @stephencottontail you are right, thanks for helping me to understand that the problem depends on the template.

    thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Theme child and new style.css’ is closed to new replies.