I created a custom page template because I wanted to do three things:
- Display an optional full width image just below the header (controlled by the featured image widget)
- Have the option to overlay the image with a call to action (text and button) controlled by a widget area
- Add other style elements, specific to the page, to reduce inline style and the use of <div></div> tags
I was able to hack together a pretty simple solution to accomplish all three functions. This is how it looks. Demo!
To apply this to your genesis child theme, (affilink) these are required:
- HTML5 Supported Theme
- The Jetpack Widget Visibility plugin (if you’re not already using Jetpack)
Let’s Get Started!
You’ll need to create a new file in your theme folder, name it page_sales.php.
Copy and past this code into that new file and save it.
This code adds the full width image feature and a new widget area to any page using this template. It also strips the page of all layout and adds a new body_class so that we can restyle the page how we want it. Step Two Next we need to register the widget area that will display on top (overlaying) of the full width image. Copy and past this code into your functions.php file at the bottom.
You’ll need to add the files listed below to your child theme folder specifically in the js folder. If you do not already have a folder labeled js, you’ll need to create one.
Copy the code from each of these files into a new file with the same name (click the links to copy the code).
Making it look pretty! Now we need to add all the elements and classes to make your newly added code look good!
Copy and past this code into your style.css file.
Install and activate the Jetpack Widget Visibility.
Once activated, your widgets will have a new feature. You’ll be able to add multiple widgets to any widget area and control when they are visible based on an if statement.
Create your new page, and in the “Page Attributes” widget, select “Sales” from the drop down menu below “Template”.
How it all works
With your code in place, you can now start to use your newly created “Sales” page template.
- To add a full width image below the header, just add a featured image to your page.
- To use the overlay widget area, add a text widget to the “Sales Page CTA” widget area, set the visibility to display on your sales page and click save (shown in step five).
- Add some content to the body of your page and when you’re ready, publish the page!
I’ve add some styling to the widget area that allows you to select large or small font size and white or black font color depending on your background image. To utilize this just wrap your text in a <div> tag like this:
<div class=”tagline size color”></div>
You would replace size with large or small and color with white or black.
- Sridhar Katakam: Many great tutorials that helped me accomplish this.
- Scott Robbin’s Backstretch jQuery plugin