-
-
Save braddalton/7fc263320d8da4185e68 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* This file adds the Home Page to the News Pro Theme. | |
* | |
* @author StudioPress | |
* @package News Pro | |
* @subpackage Customizations | |
*/ | |
add_action( 'genesis_meta', 'news_home_genesis_meta' ); | |
/** | |
* Add widget support for homepage. If no widgets active, display the default loop. | |
* | |
*/ | |
function news_home_genesis_meta() { | |
if ( is_active_sidebar( 'home-top' ) || is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-right' ) || is_active_sidebar( 'home-bottom' ) ) { | |
// Force content-sidebar layout setting | |
add_filter( 'genesis_site_layout', '__genesis_return_content_sidebar' ); | |
// Add news-home body class | |
add_filter( 'body_class', 'news_body_class' ); | |
} | |
if ( is_active_sidebar( 'home-top' ) ) { | |
// Add excerpt length filter | |
add_action( 'genesis_before_loop', 'news_top_excerpt_length' ); | |
// Add homepage widgets | |
add_action( 'genesis_before_loop', 'news_homepage_top_widget' ); | |
// Remove excerpt length filter | |
add_action( 'genesis_before_loop', 'news_remove_top_excerpt_length' ); | |
} | |
if ( is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-right' ) || is_active_sidebar( 'home-bottom' ) ) { | |
// Remove the default Genesis loop | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
// Add homepage widgets | |
add_action( 'genesis_loop', 'news_homepage_widgets' ); | |
} | |
} | |
function news_body_class( $classes ) { | |
$classes[] = 'news-pro-home'; | |
return $classes; | |
} | |
function news_excerpt_length( $length ) { | |
return 25; // pull first 50 words | |
} | |
function news_top_excerpt_length() { | |
add_filter( 'excerpt_length', 'news_excerpt_length' ); | |
} | |
function news_remove_top_excerpt_length() { | |
remove_filter( 'excerpt_length', 'news_excerpt_length' ); | |
} | |
function news_homepage_top_widget() { | |
genesis_widget_area( 'home-top', array( | |
'before' => '<div class="home-top widget-area">', | |
'after' => '</div>', | |
) ); | |
} | |
function news_homepage_widgets() { | |
if ( is_active_sidebar( 'home-middle-left' ) || is_active_sidebar( 'home-middle-right' ) ) { | |
echo '<div class="home-middle">'; | |
genesis_widget_area( 'home-middle-left', array( | |
'before' => '<div class="home-middle-left widget-area">', | |
'after' => '</div>', | |
) ); | |
genesis_widget_area( 'home-middle-right', array( | |
'before' => '<div class="home-middle-right widget-area">', | |
'after' => '</div>', | |
) ); | |
echo '</div>'; | |
} | |
genesis_widget_area( 'home-bottom', array( | |
'before' => '<div class="home-bottom widget-area">', | |
'after' => '</div>', | |
) ); | |
} | |
genesis(); |
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', 'news' ), | |
'description' => __( 'This is the top section of the homepage.', 'news' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'home-middle-left', | |
'name' => __( 'Home - Middle Left', 'news' ), | |
'description' => __( 'This is the middle left section of the homepage.', 'news' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'home-middle-right', | |
'name' => __( 'Home - Middle Right', 'news' ), | |
'description' => __( 'This is the middle right section of the homepage.', 'news' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'home-bottom', | |
'name' => __( 'Home - Bottom', 'news' ), | |
'description' => __( 'This is the bottom section of the homepage.', 'news' ), | |
) ); | |
genesis_register_sidebar( array( | |
'id' => 'after-entry', | |
'name' => __( 'After Entry', 'news' ), | |
'description' => __( 'This is the after entry section.', 'news' ), | |
) ); |
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
.home-top { | |
background-color: #f3f3f3; | |
border-bottom: 1px solid #e3e3e3; | |
clear: both; | |
padding: 20px 20px 0; | |
padding: 2rem 2rem 0; | |
} | |
.home-top .featured-content .entry-title { | |
font-size: 30px; | |
font-size: 3rem; | |
} | |
.home-middle-left { | |
border-right: 1px solid #e3e3e3; | |
float: left; | |
padding: 20px 20px 0; | |
padding: 2rem 2rem 0; | |
width: 50%; | |
} | |
.home-middle-right { | |
float: right; | |
padding: 20px 20px 0; | |
padding: 2rem 2rem 0; | |
width: 50%; | |
} | |
.home-bottom { | |
border-top: 1px solid #e3e3e3; | |
clear: both; | |
padding: 20px 20px 0; | |
padding: 2rem 2rem 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment