Forked from ChristopherNeetz/page_featured_blog.php
Last active
July 21, 2018 05:58
-
-
Save billerickson/5eff5e46db89db9b288f610d10dcf13e to your computer and use it in GitHub Desktop.
Genesis page template with full blog post and additional posts with excerpts
This file contains hidden or 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 | |
/* Template Name: Featured Blog with excerpts */ | |
/** | |
* Excerpt Length | |
* | |
*/ | |
function be_custom_excerpt_length( $length ) { | |
return 50; | |
} | |
add_filter( 'excerpt_length', 'be_custom_excerpt_length', 999 ); | |
/** | |
* Custom Loop | |
* | |
*/ | |
function be_custom_loop() { | |
$args = array( | |
'post_type' => 'post', | |
'posts_per_page' => 5, | |
); | |
genesis_custom_loop( $args ); | |
} | |
add_action( 'genesis_loop', 'be_custom_loop' ); | |
/** | |
* Full post first, followed by excerpts | |
* | |
*/ | |
function be_post_content_type( $type ) { | |
global $wp_query; | |
if( 0 == $wp_query->current_post ) | |
$type = 'full'; | |
else | |
$type = 'excerpts'; | |
return $type; | |
// I made this code more verbose so it's easy to read. | |
// Normally I'd just do a one-liner: | |
// return 0 == $wp_query->current_post ? 'full' : 'excerpts'; | |
} | |
add_filter( 'genesis_pre_get_option_content_archive', 'be_post_content_type' ); | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment