Skip to content

Instantly share code, notes, and snippets.

@chrisegg
chrisegg / page-title-widget.php
Last active Jan 1, 2016
Adds a widget area below header in Genesis child theme (Step 1 of 3)Usage: Place the following code in your themes functions.php file.
View page-title-widget.php
/**
* Add Page Title Widget Area Below Header.
*
* author ChrisEgg
* http://chriseggleston.com
* license GPL-2.0+
*/
//* Add the Page Title section
add_action( 'genesis_after_header', 'cegg_pagetitle' );
@chrisegg
chrisegg / page-title-widget-home.php
Last active Jan 1, 2016
Removes the Page Title widget area from the homepage (Step 2 of 3)Usage: Place the following code in your themes home.php or front-page.php file
View page-title-widget-home.php
//* Removes Page Title widget area from the homepage
remove_action( 'genesis_after_header', 'cegg_pagetitle' );
@chrisegg
chrisegg / page-title-widget.css
Last active Jan 1, 2016
Add this code to your themes style.css file. This code will style the widget area nicely. Feel free to edit it as needed.
View page-title-widget.css
/* Page Title
--------------------------------------------- */
.pagetitle {
background-color: #222;
border-top: 5px solid #eaeaea;
margin: 0;
margin: 0;
padding: 40px;
padding: 2rem;
@chrisegg
chrisegg / entry-background.php
Last active Aug 23, 2017
Add this code to your functions.php file. This code will add the backstretch functionality to your theme which handles the loading and sizing of the images.
View entry-background.php
<?php
//* Do NOT include the opening php tag
//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'cegg_load_scripts_styles' );
function cegg_load_scripts_styles() {
if ( is_singular( array( 'post', 'page' ) ) && has_post_thumbnail() ) {
wp_enqueue_script( 'cegg-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0', true );
View entry-background.css
/* Add style for the new page or post background image
---------------------------------------------------------- */
.entry-background {
display: block;
height: 560px;
width: 100%;
z-index: -99 !important;
}
View page_sales.php
<?php
/* Template Name: Sales
----------------------------------*/
//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'cegg_image_load_scripts_styles' );
function cegg_image_load_scripts_styles() {
if ( has_post_thumbnail() ) {
View fullwidth-image.php
<?php
//* Do NOT include the opening php tag
//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'cegg_image_load_scripts_styles' );
function cegg_image_load_scripts_styles() {
if ( has_post_thumbnail() ) {
wp_enqueue_script( 'cegg-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0', true );
wp_enqueue_script( 'cegg-backstretch-set', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch-set.js' , array( 'jquery', 'cegg-backstretch' ), '1.0.0', true );
View overlay-widgetarea.php
<?php
//* Do NOT include the opening php tag
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'sales-cta-overlay',
'name' => __( 'Sales Page CTA', 'cegg' ),
'description' => __( 'Widgets placed here will appear on top of sales page background image.', 'cegg' ),
) );
View hook-overlay-widget.php
<?php
//* Do NOT include the opening php tag
//* Add overlay widget to sales page background image
add_action( 'genesis_after_header', 'sales_image_overlay', 5 );
function sales_image_overlay() {
if ( has_post_thumbnail() ) {
echo '<div class="sales-cta"><div class="wrap">';
View cegg-sales.css
/*
Sales Page Template
-------------------------------------- */
.cegg-sales {
background: #f7f7f7;
}
.cegg-sales .head-wrap {
margin: 0;