Okay
  Public Ticket #2132852
Uku Child Theme style.css version number update
Closed

Comments

  • Sandra started the conversation

    Is there any possibility to update the version number on the style.css file of a child-theme?

    Currently it only uses the date of the installation as the version number. Right now for my website it is "?ver=20160507"

    My findings so far:

    A useful code to include in the functions.php of the child theme:

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

    But this results in two versions of the style.css getting loaded (default one with date as version and the one with the actual version from the file):

    /wp-content/themes/uku-child/style.css?ver=20160507
    /wp-content/themes/uku-child/style.css?ver=
    2.0

    Is there any way to unhook the style.css with the fixed version number?

  •  955
    Marc replied

    Hi,

    the following additional code should prevent the default enqueueing of the child theme's style.css:

    add_action( 'wp_enqueue_scripts', 'theme_dequeue_styles', 11 );
    function theme_dequeue_styles() {
      wp_dequeue_style( 'uku-style' );
    }
    

    Best,
    Marc