• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Genesis Snippets

A reference for Genesis theme developers

  • Home
  • Archives
  • Search Genesis Snippets

page layouts

Modifying the $content_width variable in Genesis

March 21, 2014 By David Wang

WordPress looks for the $content_width variable when determining the width of oEmbed items. To define this variable, you would put this in the functions.php file:

if ( ! isset( $content_width ) )
	$content_width = 600;

However this is kind of limiting especially since we can have multiple layouts in Genesis. So the Genesis team has made it easy to define different $content_widths. For Genesis child themes, we would use this instead:

$content_width = apply_filters( 'content_width', 580, 480, 900 );

The 3 numbers correspond to the content width of the default, small and large layouts. The default layout refers to 2-column layouts; small refers to 3-column layouts and large refers to the full-width content layout.

You can combine this with the following method (borrowed from Twenty Twelve) to apply a different $content_width to different contexts and page templates.

function twentytwelve_content_width() {
	if ( is_page_template( 'page-templates/full-width.php' ) || is_attachment() || ! is_active_sidebar( 'sidebar-1' ) ) {
		global $content_width;
		$content_width = 960;
	}
}
add_action( 'template_redirect', 'twentytwelve_content_width' );

See also: Brad Dalton on How To Change Content Width For Media Embeds Conditionally

Filed Under: Genesis Tagged With: media, oembed, page layouts

Remove Genesis layout settings for a Custom Post Type

July 29, 2012 By David Wang

If you’ve forced a layout for a custom post type, there’s no need to display the Layout Settings metabox in the edit screen. Here’s a code snippet that removes the layout options for a product custom post type.

/** Remove Genesis inpost layouts from 'product' post_type */
add_action( 'init', 'child_remove_post_type_support' );
function child_remove_post_type_support() {
	remove_post_type_support( 'product', 'genesis-layouts' );
}

Replace product with the custom post type you want this to work for.

Credit: Ade Walker, gleaned from his article How to use Genesis Connect for WooCommerce.

Want to remove the default layout metabox in the Genesis Theme Settings page instead? Use this snippet: Remove unused theme settings metaboxes

Filed Under: Genesis Tagged With: custom post type, metabox, page layouts, theme options

Force a layout in a template

July 29, 2012 By David Wang

Here’s a code snippet you can use when you want to lock down a layout for a specific template. Just drop the following into a single-posttype.php, template-something.php, etc before the genesis() function:

add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

Note: __genesis_return_full_width_content is a helper function built into Genesis. See the end of this post on all available helper functions: Overriding Options and Meta.

Alternate method from Brad in the comments below which can go in functions.php:

/** Force full width layout */
add_filter( 'genesis_pre_get_option_site_layout', 'child_do_layout' );
function child_do_layout( $opt ) {
	if ( is_single() ) { // Modify the conditions to apply the layout to here
		$opt = 'full-width-content'; // You can change this to any Genesis layout
		return $opt;
	}
}

As a reminder, Genesis comes with 6 default layouts:

content-sidebar
sidebar-content
content-sidebar-sidebar
sidebar-sidebar-content
sidebar-content-sidebar
full-width-content

See Brian Gardner’s post on creating a landing page in Genesis for a practical example of how you would use this.

Updated: 17 June 2013

Filed Under: Genesis Tagged With: page layouts

Remove unused page layouts

March 20, 2012 By David Wang

Genesis comes with 6 page layouts, which you may not need for every site. Here’s how to remove them.

/** Remove Unused Page Layouts */
// Un-comment the page layouts you wish to remove
//genesis_unregister_layout( 'full-width-content' );
//genesis_unregister_layout( 'content-sidebar' );	
genesis_unregister_layout( 'sidebar-content' );
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
genesis_unregister_layout( 'sidebar-content-sidebar' );

Credit: Bill Erickson

Filed Under: Genesis Tagged With: page layouts, theme options

Primary Sidebar

Brought to you by ClickWP
Buy the Genesis Theme Framework

Who’s behind this?

Hi! I'm David and I'm a big Genesis fan. I've been using it in all my projects and have found it to be super powerful.

I started this site to keep track of all the snippets that I've been using in my projects and so that it's easy for me to find them again instead of digging through my old project files.

Help support this site by buying Genesis with our affiliate links. Thanks!

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 354 other subscribers

Browse Snippets

branding cache comments css custom post type doctype entry footer entry header favicon featured image genesis_custom_loop images internet explorer jetpack loop media menu metabox minify navigation oembed page layouts performance plugin integration post thumbnail shortcode sidebars theme options widget areas widgets WooCommerce WordPress
Everything you need to support your online business
Take WordPress further with the Genesis framework

Copyright © 2025 · Genesis Sample On Genesis Framework · WordPress · Log in