Genesis child themes come with various features and widgets, however, sometimes we use page builders like Beaver Builder and Elementor to design quick great looking pages.
Well, I don’t say anything bad or good about page builders as they are good for newbie designers and we can easily create a great looking site within few minutes.
Let’s see how you can use a custom template for page builders in Genesis child theme.
Case 1. Manual Template Selection
We generally not design all the pages but want to design some of the pages using page builders so we are using custom templates in Genesis to control the template using Page attributes section.
Step 1
Create a file named say, template-full-width.php in your child theme directory and paste the following code.
<?php // Template Name: Full Width add_filter( 'genesis_attr_site-inner', 'be_site_inner_attr' ); /** * Adds the 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 ) { // Adds a class of 'full-width' for styling this .site-inner differently $attributes['class'] .= ' full-width'; // Adds an id of 'genesis-content' for accessible skip links $attributes['id'] = 'genesis-content'; // Adds 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(); genesis_do_breadcrumbs(); // Displays content. the_post(); // sets the 'in the loop' property to true. Needed for Beaver Builder but not Elementor. the_content(); // Displays comments (if any are already present and if comments are enabled in Genesis settings - disabled by default for Pages. genesis_get_comments_template(); // Displays footer. get_footer();
Step 2
Add this CSS to your child theme’s style.css
/* Full Width Page ------------------------------------------------------ */ .site-inner.full-width { max-width: none; padding: 0; margin: 0; }
Apply Full-Width template on the particular single page from the default editor “Page Attributes“.
Publish. and start working with Your Page builder.
Case 2. Auto Template Selection
WordPress offers auto template for some pages like front-page.php page.php -archive.php and more.
To use Page builder on the front page ie. home page,
Make sure you have a static page set in the Reading setting. if not,
a) Create a Page titled say, ‘Home’
b) Go to Reading setting >> Select the Homepage: Home
c) You can create a Blog page and can use it for Post page in Reading setting. Read more about this here and here.
d) Create a file named front-page.php
in the child theme directory having:
<?php get_template_part( 'template', 'full-width' );
Important:
Don’t forget to sprinkle a pinch of CSS.
/* Full Width Page ------------------------------------------------------ */ .site-inner.full-width { max-width: none; padding: 0; }
Similarity you can create an auto template for page.php
(single). Create a file page.php
and place the same code from Case 2. d)
<?php get_template_part( 'template', 'full-width' );
Enjoy.
Reference: