Last active
June 14, 2016 22:33
-
-
Save jaygidwitz/4153e7b0c29a5f87e5a8cffc88fdd1c5 to your computer and use it in GitHub Desktop.
Genesis Theme Call To Action Widget Below Header, Changes Depending on page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add CTA widget support for site. If widget not active, don't display | |
* Modified from http://www.carriedils.com/add-widget-area-below-nav/ | |
*/ | |
function mp_cta_genesis() { | |
// Don't display the CTA on the home page, since it's built into the MP theme | |
if ( is_home() || is_page('blog') || is_archive() ) { | |
return; | |
} | |
// If it's the About page, display CTA #1 | |
elseif ( is_page( 'about' ) ) { | |
genesis_widget_area( 'cta-1', array( | |
'before' => '<div id="cta"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
// If it's a page with ID 101 or 102 or any page within my Portfolio CPT | |
// Display CTA #2 | |
elseif ( is_page( array(101,102) ) || ('portfolio' == get_post_type() ) ) { | |
genesis_widget_area( 'cta-2', array( | |
'before' => '<div id="cta"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
// If it's the Contact page, display CTA #3 | |
elseif ( is_page('contact') ) { | |
genesis_widget_area( 'cta-3', array( | |
'before' => '<div id="cta"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
// If it's the About page, display CTA #1 | |
elseif ( is_page( 'work' ) ) { | |
genesis_widget_area( 'cta-5', array( | |
'before' => '<div id="cta"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
// If it's the About page, display CTA #1 | |
elseif ( is_page( 'services' ) ) { | |
genesis_widget_area( 'cta-6', array( | |
'before' => '<div id="cta"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
// If it's the About page, display CTA #1 | |
elseif ( is_page( 'about-us' ) ) { | |
genesis_widget_area( 'cta-7', array( | |
'before' => '<div id="cta"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
// If it's the 404 page, display CTA #1 | |
elseif ( is_page( '404' ) ) { | |
genesis_widget_area( 'cta-404-page', array( | |
'before' => '<div id="cta"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
// If all else fails and none of the above conditions are met, display CTA #4 | |
else { | |
genesis_widget_area( 'cta-4', array( | |
'before' => '<div id="cta"><div id="enews" class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
} | |
/** Register widget areas */ | |
genesis_register_sidebar( array( | |
'id' => 'cta-1', | |
'name' => __( 'Call to Action #1', 'altitude' ), | |
'description' => __( 'This is the call to action section.', 'altitude' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'cta-2', | |
'name' => __( 'Call to Action #2', 'altitude' ), | |
'description' => __( 'This is the call to action section.', 'altitude' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'cta-3', | |
'name' => __( 'Call to Action #3', 'altitude' ), | |
'description' => __( 'This is the call to action section.', 'altitude' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'cta-4', | |
'name' => __( 'Call to Action #4', 'altitude' ), | |
'description' => __( 'This is the call to action section.', 'altitude' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'cta-5', | |
'name' => __( 'Call to Action #5', 'altitude' ), | |
'description' => __( 'This is the call to action section.', 'altitude' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'cta-6', | |
'name' => __( 'Call to Action #6', 'altitude' ), | |
'description' => __( 'This is the call to action section.', 'altitude' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'cta-7', | |
'name' => __( 'Call to Action About Us', 'altitude' ), | |
'description' => __( 'This is the call to action section.', 'altitude' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'cta-404-page', | |
'name' => __( 'Call to Action 404', 'altitude' ), | |
'description' => __( 'This is the call to action section.', 'altitude' ), | |
) ); | |
add_action( 'genesis_after_header', 'mp_cta_genesis' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment