Last active
December 13, 2015 22:58
-
-
Save cdils/4987863 to your computer and use it in GitHub Desktop.
For use on the Genesis Modern Portfolio child theme. Create a second widget area to mimic the homepage "About" widget on other pages in the site.
This file contains 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
/** Register widget areas */ | |
genesis_register_sidebar( array( | |
'id' => 'cta-1', | |
'name' => __( 'Call to Action', 'mp' ), | |
'description' => __( 'This is the call to action section.', 'mp' ), | |
) ); | |
/** Add CTA widget support for site. If widget not active, don't display */ | |
//Adding priority 5 will make the widget appear above the primary nav. | |
//Change priority to 15 if you want primary nav above widget | |
add_action( 'genesis_after_header', 'mp_cta_genesis', 5 ); | |
function mp_cta_genesis() { | |
// MP Home page already has the About widget, so we don't want to show it | |
if ( is_home() ) { | |
return; | |
} | |
// You can create additional widgets and use multiple elseif statements with conditional checks | |
// to show different widgets on different pages | |
else { | |
genesis_widget_area( 'cta-1', array( | |
'before' => '<div id="about"><div class="wrap">', | |
'after' => '</div></div>', | |
) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment