patric-boehner
6/8/2016 - 6:51 PM

Genesis page template with full blog post and additional posts with excerpts

Genesis page template with full blog post and additional posts with excerpts

<?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();