How to Define Genesis default options

So was browsing twitter today and saw this http://twitter.com/bpmore/status/20822795914

Is it possible to define presets for #GenesisWP so that when I add new sites, I don’t have to check/uncheck various settings?

It sure is!

drop this function in your child theme’s function.php

add_filter('genesis_options', 'define_genesis_setting_custom', 10, 2);
function define_genesis_setting_custom($options, $setting) {
	if($setting == GENESIS_SETTINGS_FIELD) {
		$options['nav_type'] = 'categories';
	}
	return $options;
}

The code above will set the main navigation to use categories instead of pages ( as set by default in genesis options. )
['nav_type'] is the option want to set and 'categories' is the value.

Genesis is a great framework and has some even greater settings and options. However, it may not always be the best idea for the options to be available for a client. Sometimes to many options may be overwhelming or curiosity may strike and experimentation begin.

With this code you can set all the default values for the Genesis options and hide the menu to access them. This is great for those curious clients that love checking and unchecking boxes or not having to worry about supporting multiple layouts. Hiding the extra options and setting the default values allows your site to be kept the way you set it up to be and helps decrease the chance of an email saying that something has broken on the site (by the client messing with options; can’t promise keeping your code from breaking).

*tip – Besides defining the options to just keep clients from changing things around, this filter is also very helpful for batch genesis site making. Quickly set options for themes by just dropping your predefined options into each your child theme’s function.php.

Define Default Options

The code below is to set all the options within Genesis Settings. Each option in the list below is using the default values.

// Define Genesis Options
add_filter('genesis_options', 'define_genesis_setting_custom', 10, 2);
function define_genesis_setting_custom($options, $setting) {
	if($setting == GENESIS_SETTINGS_FIELD) {
		$options['update'] = 1;
		$options['blog_title'] = 'text';
		$options['header_right'] = 0;
		$options['site_layout'] = 'content-sidebar';
		$options['nav'] = 1;
		$options['nav_superfish'] = 1;
		$options['nav_home'] = 1;
		$options['nav_type'] = 'pages';
		$options['nav_pages_sort'] = 'menu_order';
		$options['nav_categories_sort'] = 'name';
		$options['nav_depth'] = 0;
		$options['nav_extras_enable'] = 0;
		$options['nav_extras'] = 'date';
		$options['nav_extras_twitter_id'] = '';
		$options['nav_extras_twitter_text'] = 'Follow me on Twitter';
		$options['subnav'] = 0;
		$options['subnav_superfish'] = 1;
		$options['subnav_home'] = 0;
		$options['subnav_type'] = 'categories';
		$options['subnav_pages_sort'] = 'menu_order';
		$options['subnav_categories_sort'] = 'name';
		$options['subnav_depth'] = 0;
		$options['feed_uri'] = '';
		$options['comments_feed_uri'] = '';
		$options['redirect_feeds'] = 0;
		$options['comments_pages'] = 0;
		$options['comments_posts'] = 1;
		$options['trackbacks_pages'] = 0;
		$options['trackbacks_posts'] = 1;
		$options['author_box_single'] = 1;
		$options['breadcrumb_home'] = 1;
		$options['breadcrumb_single'] = 1;
		$options['breadcrumb_page'] = 1;
		$options['breadcrumb_archive'] = 1;
		$options['breadcrumb_404'] = 1;
		$options['content_archive'] = 'full';
		$options['content_archive_thumbnail'] = 0;
		$options['posts_nav'] = 'older-newer';
		$options['blog_cat'] = '';
		$options['blog_cat_exclude'] = '';
		$options['blog_cat_num'] = 10;
		$options['header_scripts'] = '';
		$options['footer_scripts'] = '';
		$options['theme_version'] = PARENT_THEME_VERSION;
		}
	return $options;
}

View available values for each option click here (a box will appear below listing each).

Remove Access to Genesis Admin Menu

remove_theme_support('genesis-admin-menu');

Removing per Post/Page Layout Options

This one comes in handing especially for theme designs where only one layout may seem fit.

remove_theme_support('genesis-inpost-layouts');

The code above should be placed in the child theme’s functions.php file anywhere after the following line:

require_once(TEMPLATEPATH.'/lib/init.php');

And before the following closing code (if it exists):

?>

Trackbacks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>