Skip to content

Genesis Developer Docs

Genesis Constants

Directory and URL constants

These constants are available to child theme developers for convenience and performance:

Constant Equivalent
PARENT_DIR get_template_directory()
CHILD_DIR get_stylesheet_directory()
PARENT_URL get_template_directory_uri()
CHILD_URL get_stylesheet_directory_uri()

You can use the code in the Constant column wherever you might use the code in the Equivalent column in your child theme. So instead of:

wp_enqueue_script(
'custom-theme',
get_stylesheet_directory_uri() . '/js/custom-theme.js',
array( 'jquery' ),
wp_get_theme()->get( 'Version' ),
true
);

You can do this for brevity and to avoid an additional function call:

wp_enqueue_script(
'custom-theme',
CHILD_URL . '/js/custom-theme.js', // <-- Constant used here.
array( 'jquery' ),
wp_get_theme()->get( 'Version' ),
true
);

Additional constants

Genesis uses additional constants that are mostly useful for those contributing to Genesis itself:

Constant Example Values
PARENT_THEME_NAME Genesis
PARENT_THEME_VERSION 2.8.0, 2.8.0-beta2
PARENT_THEME_BRANCH 2.8
GENESIS_IMAGES_URL https://example.com/wp-content/themes/genesis/images
GENESIS_ADMIN_IMAGES_URL https://example.com/wp-content/themes/genesis/lib/admin/images
GENESIS_CSS_URL https://example.com/wp-content/themes/genesis/lib/css
GENESIS_VIEWS_DIR /path/to/site/wp-content/themes/genesis/lib/views
GENESIS_CONFIG_DIR /path/to/site/wp-content/themes/genesis/config
GENESIS_SETTINGS_FIELD genesis-settings
GENESIS_SEO_SETTINGS_FIELD genesis-seo-settings
GENESIS_CPT_ARCHIVE_SETTINGS_FIELD_PREFIX genesis-cpt-archive-settings-

Testing for Genesis features

It is generally better to test for a specific function or class rather than using the Genesis version constants. We recommend this:

if ( function_exists( 'genesis_get_config' ) ) {
// `genesis_get_config()` exists and is safe to use.
}

Over comparisons like this:

if ( version_compare( PARENT_THEME_VERSION, '2.8.0', '>=' ) ) {
// Genesis version is 2.8.0 or higher.
}

Checking for the function by name ensures your code will not throw a fatal error if that function is deprecated and removed in a future version of Genesis.