By default Genesis uses the parent theme for the version number for style.css
.
URL Parameter
This version number is used in the ver
URL parameter, e.g.
https://example.com/wp-content/themes/bootstrap4-genesis/style.css?ver=2.8.1
where 2.8.1
is the version of Genesis running. This ver
parameter is particularly helpful for cache busting (i.e. forcing the browser to load the latest version when when the file changes).
Setting URL Parameter in Genesis
We can replace this number by defining CHILD_THEME_VERSION
in our PHP code (e.g. in functions.php
).
define( 'CHILD_THEME_VERSION', '7.8.9' );
Now, the value of ver
will be 7.8.9
.
https://example.com/wp-content/themes/bootstrap4-genesis/style.css?ver=7.8.9
Use the Version in style.css
Since we are already defining the theme version number in the header of style.css
/**
* Theme Name: Bootstrap4 Genesis
* Theme URI: https://github.com/salcode/bootstrap4-genesis
* Author: Sal Ferrarello
* Author URI: https://salferrarello.com
* Description: WordPress Genesis Child Theme using Bootstrap 4
* Version: 1.0.0
We can read this value with wp_get_theme()->get( 'Version' )
and set CHILD_THEME_VERSION
to this value.
if ( ! defined( 'CHILD_THEME_VERSION' ) ) {
define( 'CHILD_THEME_VERSION', wp_get_theme()->get( 'Version' ) );
}
Now the version defined in style.css
will be used for the ver
URL parameter when style.css
is loaded.
Other CHILD_THEME_ Constants
You can also define Genesis’s CHILD_THEME_NAME
and CHILD_THEME_URL
(these values are used in the default Genesis footer) based on the header values in style.css
.
if ( ! defined( 'CHILD_THEME_NAME' ) ) {
define( 'CHILD_THEME_NAME', wp_get_theme()->get( 'Name' ) );
}
if ( ! defined( 'CHILD_THEME_URL' ) ) {
define( 'CHILD_THEME_URL', wp_get_theme()->get( 'ThemeURI' ) );
}
You can see this code being used in my Bootstrap 4 Genesis starter theme.
Leave a Reply