• Resolved aloeroot

    (@aloeroot)


    Thanks in advance for your help. I’m trying to make a child theme for Sigma and I don’t know how and where to insert the code that overrides the parent’s style sheet.

    I was able to create and activate a child theme, but it’s not looking in the right place for the child theme’s CSS and I’m stumped. Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter aloeroot

    (@aloeroot)

    Thanks fevered; I guess I should have mentioned that the standard procedure doesn’t work in this case.

    The theme’s style.css file is just a placeholder, and the actual style sheets are in /assets/css/ subfolders. I can’t figure out how to configure the call to the style sheet and where to put it.

    The child theme keeps referencing the min.css file from the parent theme, and I can’t find any references to the main stylesheet, sigma.css, anywhere in the template files.

    This is far from a standard setup.

    Yeah, instead of the standard procedure, you need to do things a bit differently for this theme. You need two files: style.css and functions.php. Your style.css should look like this:

    /*
    Theme Name: Sigma Child
    Template: sigma
    */
    
    /* Theme customizations go below this line
    ----*/

    And in your functions.php:

    <?php
    function sigma_child_scripts() {
      wp_enqueue_style( 'sigma-parent', get_template_directory_uri() . '/assets/css/sigma.min.css' );
      wp_enqueue_style( 'sigma-child', get_stylesheet_uri(), array( 'sigma-parent' ) );
    }
    add_action( 'wp_enqueue_scripts', 'sigma_child_scripts' );
    Thread Starter aloeroot

    (@aloeroot)

    Thanks very much. I see how this should have done the trick, but I’m now seeing this in the source:

    <link rel='stylesheet' id='sigma-parent-css'  href='https://site.com/newsite/wp-content/themes/sigma/assets/css/sigma.min.css?ver=4.0' type='text/css' media='all' />
    <link rel='stylesheet' id='sigma-child-css'  href='https://site.com/newsite/wp-content/themes/sigmachild/style.css?ver=4.0' type='text/css' media='all' />
    <link rel='stylesheet' id='sigmatheme-css'  href='https://site.com/newsite/wp-content/themes/sigma/assets/css/sigma.min.css?ver=0.1.2' type='text/css' media='all' />

    The calls to sigma-parent and sigma-child are there, but the original call to sigmatheme-css seems to be enqeued lower down, still, so my customizations aren’t working. I tried deregistering sigmatheme-css in the functions file but I’m not doing it right, clearly.

    Try this function, instead:

    <?php
    function sigma_child_scripts() {
      wp_dequeue_style( 'sigmatheme' );
      wp_enqueue_style( 'sigma-parent', get_template_directory_uri() . '/assets/css/sigma.min.css' );
      wp_enqueue_style( 'sigma-child', get_stylesheet_uri(), array( 'sigma-parent' ) );
    }
    add_action( 'wp_enqueue_scripts', 'sigma_child_scripts', 20 );
    Thread Starter aloeroot

    (@aloeroot)

    Ah, I hadn’t configured the “dequeue” line properly, among other things – thank you SO much for your help. That worked.

    Hareesh S

    (@hareesh-pillai)

    Hi aloeroot, mark this topic as resolved, if you’ve found what you were looking for! Have a good day.

    Thread Starter aloeroot

    (@aloeroot)

    Right; thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to create a child theme?’ is closed to new replies.