Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active December 24, 2015 20:19
Show Gist options
  • Save srikat/6857133 to your computer and use it in GitHub Desktop.
Save srikat/6857133 to your computer and use it in GitHub Desktop.
Code to add in Sixteen Nine Pro's functions.php to add a Home Featured widget area above posts on homepage. http://sridharkatakam.com/add-home-featured-section-posts-homepage-sixteen-nine-pro/
<?php
//* Do NOT include the opening php tag
genesis_register_sidebar( array(
'id' => 'home-featured',
'name' => __( 'Home Featured', 'sixteen-nine' ),
'description' => __( 'This is the home featured section.', 'sixteen-nine' ),
) );
/** Add the home featured section */
add_action( 'genesis_before_loop', 'sixteen_nine_home_featured' );
function sixteen_nine_home_featured() {
if ( is_home() && !get_query_var( 'paged' ) >= 2 ) {
genesis_widget_area( 'home-featured', array(
'before' => '<div class="home-featured widget-area">',
'after' => '</div>'
) );
}
}
.home-featured {
margin-bottom: 2rem;
}
.home-featured .widgettitle {
color: #333;
}
//* Add new image size
add_image_size( 'below-home-featured', 205, 168, TRUE );
.home-featured .widget {
margin-bottom: 3rem;
}
.home-featured .entry {
border-bottom: none;
width: 23.2954545455%;
}
.home-featured .entry img {
vertical-align: top;
}
.home-featured .entry:nth-of-type(4n+1),
.home-featured .entry:nth-of-type(4n+2),
.home-featured .entry:nth-of-type(4n+3) {
float: left;
margin-right: 2.2727272727%;
}
.home-featured .entry:nth-of-type(4n+0) {
float: right;
}
@media only screen and (max-width: 480px) {
.home-featured .entry {
width: 48.046875%;
}
.home-featured .entry:nth-of-type(4n+1),
.home-featured .entry:nth-of-type(4n+3) {
margin-right: 3.90625%;
}
.home-featured .entry:nth-of-type(4n+2) {
margin-right: 0;
float: right;
}
}
@media only screen and (max-width: 320px) {
.home-featured .entry {
width: 100%;
text-align: center;
}
.home-featured .entry:nth-of-type(4n+1),
.home-featured .entry:nth-of-type(4n+3) {
margin-right: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment