Run Code During Genesis Theme Setup
Requires Genesis 2.10.0+ and WordPress 5.0.0+
One-click theme setup #
- Theme setup introduction.
- See full onboarding examples.
- Install plugins.
- Import content.
- Set up navigation.
- Import widgets.
- Run code.
- Create Starter Packs.
- Update theme settings.
Run code before and after importing content #
To run code before content is imported during theme setup, use the genesis_onboarding_before_import_content
action:
add_action( 'genesis_onboarding_before_import_content', 'theme_prefix_onboarding_before_import_content' );
/**
* Runs code before content is imported during theme setup.
*
* @since 1.0.0
*
* @param array $content The content data from the `onboarding.php` file.
*/
function theme_prefix_onboarding_before_import_content( $content ) {
// Code you would like to run before content is imported.
}
To run code after content is imported during theme setup, use the genesis_onboarding_after_import_content
action:
add_action( 'genesis_onboarding_after_import_content', 'theme_prefix_onboarding_after_import_content', 10, 2 );
/**
* Runs code after content is imported during theme setup.
*
* @since 1.0.0
*
* @param array $content The content data from the `onboarding.php` file.
* @param array $imported_post_ids Content keys and created post IDs. Example: `[ "homepage" => 123 ]`.
*/
function theme_prefix_onboarding_after_import_content( $content, $imported_post_ids ) {
// Code you would like to run after content is imported.
}
For an example of how Genesis uses this hook, see the genesis_onboarding_import_widgets()
function in wp-content/themes/genesis/lib/functions/onboarding.php
.