Last active
August 2, 2018 18:26
-
-
Save braddalton/a2ab5a33fb9dd45996018635d046a818 to your computer and use it in GitHub Desktop.
Move Home Top Widget Before Content Sidebar Magazine Pro https://wp.me/p1lTu0-hEI
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
<?php | |
/** | |
* Magazine Pro. | |
* | |
* This file adds the front page to the Magazine Pro Theme. | |
* | |
* @package Magazine | |
* @author Brad Dalton | |
* @license GPL-2.0+ | |
* @link https://wp.me/p1lTu0-hEI | |
*/ | |
add_action( 'genesis_meta', 'magazine_home_genesis_meta' ); | |
/** | |
* Add widget support for homepage. If no widgets active, display the default loop. | |
* | |
* @since 3.0.0 | |
*/ | |
function magazine_home_genesis_meta() { | |
if ( is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-middle' ) || is_active_sidebar( 'home-bottom' ) ) { | |
// Force content-sidebar layout setting. | |
add_filter( 'genesis_site_layout', '__genesis_return_content_sidebar' ); | |
// Add magazine-home body class. | |
add_filter( 'body_class', 'magazine_body_class' ); | |
// Remove the default Genesis loop. | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
// Add hometop widget. | |
add_action( 'genesis_before_content_sidebar_wrap', 'magazine_hometop_widget' ); | |
// Add homepage widgets. | |
add_action( 'genesis_loop', 'magazine_homepage_widgets' ); | |
} | |
} | |
// Add body class to front page. | |
function magazine_body_class( $classes ) { | |
$classes[] = 'magazine-home'; | |
return $classes; | |
} | |
// Output the widget areas for the front page. | |
function magazine_hometop_widget() { | |
echo '<h2 class="screen-reader-text">' . __( 'Main Content', 'magazine-pro' ) . '</h2>'; | |
genesis_widget_area( 'home-top', array( | |
'before' => '<div class="home-top widget-area">', | |
'after' => '</div>', | |
) ); | |
} | |
// Output the widget areas for the front page. | |
function magazine_homepage_widgets() { | |
genesis_widget_area( 'home-middle', array( | |
'before' => '<div class="home-middle widget-area">', | |
'after' => '</div>', | |
) ); | |
genesis_widget_area( 'home-bottom', array( | |
'before' => '<div class="home-bottom widget-area">', | |
'after' => '</div>', | |
) ); | |
} | |
// Run the Genesis loop. | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment