• Resolved jmonesti

    (@jmonesti)


    Hello Kathryn !

    I’m using a child theme of sorbet, and would like to version (query string) my stylesheet.

    Until now, I was simply
    @import url("../sorbet/style.css");
    in my child stylesheet.

    After much reading, I’ve tried what’s suggested in the Codex, so that my (child) function.php now shows:

    /**
     * JFM was here
     * enqueue css stylesheet 'the proper way'
     * cf. https://codex.www.ads-software.com/Child_Themes
     *
     */
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'sorbet', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'sorbet-child', get_stylesheet_uri(), array( 'sorbet' ), 'jeff' );
    }

    Plz note the ‘jeff’ version ??

    Unfortunately, this generates:

    <link rel='stylesheet' id='sorbet-css'  href='https://-----/wp-content/themes/sorbet/style.css?ver=4.0.1' type='text/css' media='all' />
    <link rel='stylesheet' id='sorbet-child-css'  href='https://-----/wp-content/themes/sorbet-child/style.css?ver=jeff' type='text/css' media='all' />
    <link rel='stylesheet' id='sorbet-style-css'  href='https://-----/wp-content/themes/sorbet-child/style.css?ver=4.0.1' type='text/css' media='all' />

    I’m pleased with the two first <link>, but the third one seems originated from sorbet/function.php, line 115 (function sorbet_scripts), and I don’t know how to get rid of it…

    Any help would be greatly appreciated

    Merry Christmas !

Viewing 1 replies (of 1 total)
  • Thread Starter jmonesti

    (@jmonesti)

    Okay…

    Here is the piece of code I ended up with

    /**
     * JFM was here
     * enqueue css stylesheet 'the proper way'
     * cf. https://codex.www.ads-software.com/Child_Themes
     *
     */
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
    	wp_enqueue_style( 'sorbet', get_template_directory_uri() . '/style.css' );
    	wp_enqueue_style( 'sorbet-child', get_stylesheet_uri(), array( 'sorbet' ), filemtime( get_stylesheet_directory() . '/style.css') );
    }
    
    add_action( 'wp_enqueue_scripts', 'theme_dequeue_styles', 20 );
    function theme_dequeue_styles() {
    	wp_dequeue_style( 'sorbet-style' );
    }

    which generates

    <link rel='stylesheet' id='sorbet-css'  href='https://-----/wp-content/themes/sorbet/style.css?ver=4.0.1' type='text/css' media='all' />
    <link rel='stylesheet' id='sorbet-child-css'  href='https://-----/wp-content/themes/sorbet-child/style.css?ver=1419767419' type='text/css' media='all' />

    I know I could have done everything in the function theme_enqueue_styles (giving it priority 20), but this slightly alters ordering of css inclusion…

    Bye !

Viewing 1 replies (of 1 total)
  • The topic ‘Versionning the stylesheet’ is closed to new replies.