-
-
Save 10h30/8f67cc4866af691a86cf to your computer and use it in GitHub Desktop.
Features and Teasers in Genesis. http://sridharkatakam.com/features-teasers-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
<?php | |
//* Do NOT include the opening php tag | |
add_action( 'pre_get_posts', 'sk_change_blog_home_posts_per_page' ); | |
/** | |
* Change Posts Per Page for Blog Home | |
* | |
* @author Bill Erickson (original), changed by Sridhar Katakam | |
* @link http://www.billerickson.net/customize-the-wordpress-query/ | |
* @param object $query data | |
* | |
*/ | |
function sk_change_blog_home_posts_per_page( $query ) { | |
if( $query->is_main_query() && !is_admin() && is_home() ) { | |
$query->set( 'posts_per_page', '8' ); | |
} | |
} |
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 | |
//* Do NOT include the opening php tag | |
// Conditionally break posts (from 3rd onwards) into 2 columns with featured post on first page | |
add_filter( 'post_class', 'sk_blog_home_post_class' ); | |
function sk_blog_home_post_class( $classes ) { | |
if ( is_home() ) { | |
global $wp_query; | |
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; | |
// Check if on first page of pagination | |
if ( 1 == $paged ) { | |
if ( 1 >= $wp_query->current_post ) { | |
// Don't add a class to first and second posts | |
$classes[] = ''; | |
} else { | |
// Add .one-half to all posts besides first and second | |
$classes[] = 'one-half'; | |
} | |
// Skip the first and second posts and add .first to every other | |
if ( 0 == $wp_query->current_post % 2 ) { | |
$classes[] = 'first'; | |
} | |
} else { | |
// On all other pages add .one-half to all posts | |
$classes[] = 'one-half'; | |
// Add .first to every other post | |
if ( 0 == $wp_query->current_post % 2 ) { | |
$classes[] = 'first'; | |
} | |
} | |
} | |
return $classes; | |
} | |
add_action( 'genesis_before_loop', 'sk_custom_content_display' ); | |
/** | |
* Show full content for first 2 posts on first page | |
* and exerpts/content per Content Archives settings on paginated pages (second, third and so on..). | |
* | |
* Scope: Posts page and all archives. | |
* | |
* @author Sridhar Katakam | |
* @link http://sridharkatakam.com/show-full-content-first-2-posts-first-page-posts-page-archives-genesis/ | |
*/ | |
function sk_custom_content_display() { | |
if ( ( is_home() || is_archive() ) && ! is_paged() ) { | |
add_filter( 'genesis_pre_get_option_content_archive_thumbnail', 'sk_return_zero' ); | |
add_filter( 'genesis_pre_get_option_content_archive', 'sk_return_full' ); | |
add_filter( 'genesis_pre_get_option_content_archive_limit', 'sk_return_zero' ); | |
} | |
} | |
function sk_return_zero() { | |
global $wp_query; | |
if ( ( $wp_query->current_post <= 1 ) ) { | |
return '0'; | |
} | |
} | |
function sk_return_full() { | |
global $wp_query; | |
if ( ( $wp_query->current_post <= 1 ) ) { | |
return 'full'; | |
} | |
} |
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 | |
//* Add support for Genesis Grid Loop | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
add_action( 'genesis_loop', 'child_grid_loop_helper' ); | |
function child_grid_loop_helper() { | |
if ( function_exists( 'genesis_grid_loop' ) ) { | |
genesis_grid_loop( array( | |
'features' => 2, | |
'feature_image_size' => 0, | |
'feature_image_class' => 'alignleft post-image', | |
'feature_content_limit' => 0, | |
'grid_image_size' => 'medium', | |
// 'grid_image_class' => 'alignleft post-image', | |
'grid_image_class' => '', | |
'grid_content_limit' => 0, | |
// 'more' => __( '[Continue reading...]', 'genesis' ), | |
'more' => '', | |
) ); | |
} else { | |
genesis_standard_loop(); | |
} | |
} | |
//* Remove the post meta function for front page only | |
// remove_action( 'genesis_after_post_content', 'genesis_post_meta' ); | |
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
/* Featured Post Grid | |
------------------------------------------------------------ */ | |
.genesis-grid-even { | |
float: right; | |
/* padding: 0 0 15px; */ | |
width: 48%; | |
} | |
.genesis-grid-odd { | |
clear: both; | |
float: left; | |
/* padding: 0 0 15px ; */ | |
width: 48%; | |
} | |
.genesis-grid-even, | |
.genesis-grid-odd { | |
margin: 0 0 20px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment