Design System is here - Read the release post

Learn GeneratePress

Developers

Settings defaults filters

The option_generate_* family: WordPress core option filters that let you change a module’s whole Customizer settings array under conditions you choose.

Jump to

Option filters

option_generate_settings

GP Free

The option_generate_settings filter lets you change the free theme’s Customizer settings under conditions you choose — it receives the whole settings array, keyed by option name.

Parameters: $options (array, every free-theme Customizer setting, keyed by option name). Default: the saved Customizer settings.

add_filter( 'option_generate_settings','lh_single_posts_settings' );
function lh_single_posts_settings( $options ) {
    if ( is_single() ) {
        $options['nav_position_setting'] = 'nav-above-header';
        $options['nav_alignment_setting'] = 'center';
    }

    return $options;
}

Every Free setting name is listed in each guide’s All options table, for example Header — All options and Navigation — All options.

option_generate_blog_settings

GP Premium — Blog module.

The option_generate_blog_settings filter lets you change the Blog module’s Customizer settings under conditions you choose — it receives the whole Blog settings array.

Parameters: $options (array, every Blog module Customizer setting, keyed by option name). Default: the saved Blog module settings.

add_filter( 'option_generate_blog_settings', 'lh_custom_search_results_page_settings' );
function lh_custom_search_results_page_settings( $options ) {
    if ( is_search() ) {
	$options['read_more_button'] = true;
	$options['date'] = false;
	$options['categories'] = false;
	$options['tags'] = false;
	$options['comments'] = false;
        $options['infinite_scroll'] = true;
	$options['infinite_scroll_button'] = true;
	$options['masonry_load_more'] = 'More search results';
	$options['post_image'] = true;
	$options['post_image_position'] = 'post-image-above-header';
	$options['post_image_alignment'] = 'post-image-aligned-center';
	$options['column_layout'] = false;
	$options['featured_column'] = true;
	$options['masonry'] = false;
    }

    return $options;
}

Every Blog setting name is listed in Blog — All options.

option_generate_secondary_nav_settings

GP Premium — Secondary Nav module.

The option_generate_secondary_nav_settings filter lets you change the Secondary Nav module’s Customizer settings under conditions you choose — it receives the whole Secondary Nav settings array.

Parameters: $options (array, every Secondary Nav module Customizer setting, keyed by option name). Default: the saved Secondary Nav module settings.

add_filter( 'option_generate_secondary_nav_settings','lh_single_posts_secondary_nav_settings' );
function lh_single_posts_secondary_nav_settings( $options ) {
    if ( is_single() ) {
        $options['secondary_nav_position_setting'] = 'secondary-nav-above-header';
        $options['secondary_nav_alignment'] = 'center';
    }

    return $options;
}

Every Secondary Nav setting name is listed in Secondary Navigation — All options.

option_generate_menu_plus_settings

GP Premium — Menu Plus module.

The option_generate_menu_plus_settings filter lets you change the Menu Plus module’s Customizer settings under conditions you choose — it receives the whole Menu Plus settings array (mobile header, sticky navigation, off-canvas panel and more).

Parameters: $options (array, every Menu Plus module Customizer setting, keyed by option name). Default: the saved Menu Plus module settings.

add_filter( 'option_generate_menu_plus_settings','lh_custom_homepage_menu_plus_settings' );
function lh_custom_homepage_menu_plus_settings( $options ) {
    if ( is_front_page() ) {
        $options['mobile_menu_label'] = 'Home Page Toggle Text';
        $options['sticky_menu'] = 'off';
        $options['mobile_header'] = 'enable';
        $options[‘mobile_header_sticky’] = 'enable';
        $options[‘mobile_header_auto_hide_sticky’] = 'false';
    }

    return $options;
}

Note

TODO(David) — this example, carried over character for character from the original doc, uses curly quotes (‘mobile_header_sticky’) around two array keys instead of straight quotes. As written this is a PHP parse error.

Menu Plus settings are split across Header — Mobile header, Sticky Navigation and Off-Canvas Panel; each guide’s All options table lists its setting names.

Back to top