Last active
October 23, 2017 09:21
-
-
Save braddalton/803a80330004f62b8f10e51266665e93 to your computer and use it in GitHub Desktop.
Lifestyle Pro Blog Page Like Front Page - Fully suppported version https://wpsites.net/web-design/lifestyle-pro-blog-page-template-like-home/
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' => 'home-top', | |
'name' => __( 'Home - Top', 'lifestyle-pro' ), | |
'description' => __( 'This is the top section of the homepage.', 'lifestyle-pro' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'home-middle', | |
'name' => __( 'Home - Middle', 'lifestyle-pro' ), | |
'description' => __( 'This is the middle section of the homepage.', 'lifestyle-pro' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'home-bottom-left', | |
'name' => __( 'Home - Bottom Left', 'lifestyle-pro' ), | |
'description' => __( 'This is the bottom left section of the homepage.', 'lifestyle-pro' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'home-bottom-right', | |
'name' => __( 'Home - Bottom Right', 'lifestyle-pro' ), | |
'description' => __( 'This is the bottom right section of the homepage.', 'lifestyle-pro' ), | |
) ); | |
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 | |
/** | |
* Lifestyle Pro. | |
* | |
* Template Name: Like Front Page | |
* | |
* @author Brad Dalton | |
* @license GPL-2.0+ | |
* @link https://wpsites.net/web-design/lifestyle-pro-blog-page-template-like-home/ | |
*/ | |
add_action( 'genesis_meta', 'lifestyle_home_genesis_meta' ); | |
/** | |
* Add widget support for homepage. If no widgets active, display the default loop. | |
* | |
* @since 3.0.0 | |
*/ | |
function lifestyle_home_genesis_meta() { | |
if ( is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-middle' ) || is_active_sidebar( 'home-bottom-left' ) || is_active_sidebar( 'home-bottom-right' ) ) { | |
// Force content-sidebar layout setting. | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' ); | |
// Add lifestyle-pro-home body class. | |
add_filter( 'body_class', 'lifestyle_body_class' ); | |
// Remove the default Genesis loop. | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
// Add homepage widgets. | |
add_action( 'genesis_loop', 'lifestyle_homepage_widgets' ); | |
} | |
} | |
function lifestyle_body_class( $classes ) { | |
$classes[] = 'lifestyle-pro-home'; | |
return $classes; | |
} | |
function lifestyle_homepage_widgets() { | |
echo '<h2 class="screen-reader-text">' . __( 'Main Content', 'lifestyle-pro' ) . '</h2>'; | |
genesis_widget_area( 'home-top', array( | |
'before' => '<div class="home-top widget-area">', | |
'after' => '</div>', | |
) ); | |
genesis_widget_area( 'home-middle', array( | |
'before' => '<div class="home-middle widget-area">', | |
'after' => '</div>', | |
) ); | |
if ( is_active_sidebar( 'home-bottom-left' ) || is_active_sidebar( 'home-bottom-right' ) ) { | |
echo '<div class="home-bottom">'; | |
genesis_widget_area( 'home-bottom-left', array( | |
'before' => '<div class="home-bottom-left widget-area">', | |
'after' => '</div>', | |
) ); | |
genesis_widget_area( 'home-bottom-right', array( | |
'before' => '<div class="home-bottom-right widget-area">', | |
'after' => '</div>', | |
) ); | |
echo '</div>'; | |
} | |
} | |
// Run the Genesis loop. | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment