This article provides the steps to set up a full-width widgetized front page (with fixed-width content) in Genesis running on Genesis Sample 2.6.0 and above based on this article from Bill Erickson.
Step 1
Let’s register 4 front page widget areas.
Add the following in child theme’s functions.php:
// Registers front-page widget areas.
for ( $i = 1; $i <= 4; $i++ ) {
genesis_register_widget_area(
array(
'id' => "front-page-{$i}",
'name' => __( "Front Page {$i}", 'genesis-sample' ),
'description' => __( "This is the front page {$i} section.", 'genesis-sample' ),
)
);
}
Step 2
Create a file named front-page.php having the following:
<?php
/**
* Homepage Template.
*/
add_filter( 'genesis_attr_site-inner', 'be_site_inner_attr' );
/**
* Adds attributes from 'entry', since this replaces the main entry.
*
* @author Bill Erickson
* @link http://www.billerickson.net/full-width-landing-pages-in-genesis/
*
* @param array $attributes Existing attributes.
* @return array Amended attributes.
*/
function be_site_inner_attr( $attributes ) {
// Add a class of 'full' for styling this .site-inner differently.
$attributes['class'] .= ' full';
// Add an id of 'genesis-content' for accessible skip links.
$attributes['id'] = 'genesis-content';
// Add the attributes from .entry, since this replaces the main entry.
$attributes = wp_parse_args( $attributes, genesis_attributes_entry( array() ) );
return $attributes;
}
// Displays header.
get_header();
// Displays front-page widget areas.
for ( $i = 1; $i <= 4; $i++ ) {
genesis_widget_area( "front-page-{$i}", array(
'before' => '<div class="front-page-' . $i . ' widget-area"><div class="wrap">',
'after' => '</div></div>',
) );
}
// Displays Footer.
get_footer();
Step 3
Add the following above the media queries in child theme’s style.css:
/* Front Page with Full-Width Sections
-------------------------------------------- */
.site-inner.full {
max-width: none;
padding: 0;
}
.site-inner.full .wrap {
max-width: 1140px;
margin: 0 auto;
padding-left: 30px;
padding-right: 30px;
}
.site-inner.full .widget-area {
padding: 50px 0;
}
.site-inner.full .widget-area:nth-child(odd) {
background-color: rgba(0,0,0,.03);
}
.site-inner.full .widget:last-child {
margin-bottom: 0;
}
Step 4
Create a static Page titled say, Home
and set it as static homepage at Settings > Reading.
If you wish to have the list of blog posts appear at /blog, create a static Page titled Blog
(DO NOT apply the “Blog” Template to this Page) and select it as the Posts page.
Step 5
At Appearance > Widgets, drag your desired widgets into the Front Page 1, Front Page 2, Front Page 3 and Front Page 4 widget areas.
Thank you for sharing this tutorial!
Should this work with Showcase Pro (version 2) as well?
I am getting a
Fatal error: Call to undefined function genesis_register_widget_area()
in the function.php
In the register function I changed ‘genesis-sample’ to ‘showcase-pro’.
Thank you very much,
kimoribj
Not sure I understand the point of implementing this in a theme like Showcase Pro that already has a widgetized front page .
If you are wanting to apply this tutorial in Showcase Pro, you might as well just switch the theme to Genesis Sample and use it. Isn’t it?
This is really useful Sridhar, thank you. How would I go about merging your Flexible widgets tutorial with this one? I tried altering the ‘Home-featured’ example you provided in that tutorial but got a fatal error.
In
front-page.php
replacewith
Thank you so much Sridhar, that worked like a charm!!!
Just a note that after I added this, although the flexible widget layout was active within the full width widget areas, I could no longer target each widget area with CSS (.front-page-1 etc). The individual widget areas had no unique class or id.
Hi. I am using this technique on a new web site and for some reason, the Welcome section appears on all pages, not just front-page.php. Is this normal?
https://typistry.net
I am using that technique along with the custom front-page widgetized area so maybe that is the issue.
What is the code to display the Welcome section and in which file is it present?
The code in the functions.php file is directly from this tutorial:
https://sridharkatakam.com/set-welcome-section-image-left-text-widget-right-genesis/
Should it matter that I am using the latest Genesis Sample theme?
BTW, I tried disabling my plugins, too, to make sure none of those were the culprit, and that didn’t seem to matter. The welcome panel appears on all pages, even the blog page.
You know what? I think I know what the issue is.
I am also using the front page widgetized area and I have front-page.php there. Not just plain old Genesis default template.