|
<?php |
|
/** |
|
* Archive |
|
* |
|
* @package BE_Genesis_Child |
|
* @since 1.0.0 |
|
* @link https://github.com/billerickson/BE-Genesis-Child |
|
* @author Bill Erickson <[email protected]> |
|
* @copyright Copyright (c) 2011, Bill Erickson |
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
* |
|
*/ |
|
|
|
|
|
/** Setup **/ |
|
|
|
// Body Class |
|
add_filter( 'body_class', 'be_archive_body_class' ); |
|
|
|
// Post Classes |
|
add_filter( 'post_class', 'be_archive_post_classes' ); |
|
|
|
// Featured Image |
|
add_action( 'genesis_before_post_content', 'be_archive_featured_image' ); |
|
|
|
// Teaser Open |
|
add_action( 'genesis_before_post', 'be_teaser_open' ); |
|
|
|
// Teaser Divider |
|
add_action( 'genesis_after_post', 'be_teaser_divider' ); |
|
|
|
// Teaser Close |
|
add_action( 'genesis_after_post', 'be_teaser_close' ); |
|
|
|
// Customize Read More Link |
|
add_filter( 'get_the_content_more_link', 'be_more_link' ); |
|
|
|
// Customize Post Info |
|
add_filter( 'genesis_post_info', 'be_archive_post_info' ); |
|
|
|
// Shorten Excerpt for Teasers |
|
add_filter( 'genesis_pre_get_option_content_archive_limit', 'be_shorten_excerpt_for_teasers' ); |
|
|
|
// Customize Post Meta |
|
add_filter( 'genesis_post_meta', 'be_archive_post_meta' ); |
|
|
|
/** |
|
* Archive Body Class |
|
* |
|
*/ |
|
function be_archive_body_class( $classes ) { |
|
if( !in_array( 'archive', $classes ) ) |
|
$classes[] = 'archive'; |
|
|
|
return $classes; |
|
} |
|
|
|
/** |
|
* Archive Post Classes |
|
* |
|
* @param array $classes |
|
* @return array |
|
*/ |
|
function be_archive_post_classes( $classes ) { |
|
|
|
$features = 2; |
|
// Number of teasers is what's left over |
|
$columns_of_teasers = 2; |
|
|
|
|
|
global $wp_query; |
|
if( $wp_query->query_vars['paged'] == 0 && $wp_query->current_post < $features ) |
|
$classes[] = 'feature'; |
|
else { |
|
$classes[] = 'teaser'; |
|
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns_of_teasers ) |
|
$classes[] = 'left'; |
|
else |
|
$classes[] = 'right'; |
|
} |
|
|
|
$page = $wp_query->query_vars['paged'] ? $wp_query->query_vars['paged'] : 1; |
|
// Adds a class of 'last' to the last teaser |
|
if( ( ( $wp_query->query_vars['posts_per_page'] - 1 ) == $wp_query->current_post) || ( $wp_query->query_vars['posts_per_page'] * ( $page - 1 ) + ( $wp_query->current_post + 1 ) == $wp_query->found_posts ) ) |
|
$classes[] = 'last'; |
|
|
|
return $classes; |
|
} |
|
|
|
/** |
|
* Archive Featured Image |
|
* |
|
*/ |
|
function be_archive_featured_image() { |
|
$image_size = in_array( 'feature', get_post_class() ) ? 'be_large' : 'be_small'; |
|
global $post; |
|
echo '<p class="featured-image"><a href="' . get_permalink() . '">' . get_the_post_thumbnail( $post->ID, $image_size ) . '</a></p>'; |
|
} |
|
/** |
|
* Teaser Open |
|
* |
|
*/ |
|
function be_teaser_open() { |
|
global $wp_query; |
|
if( ( 0 == $wp_query->query_vars['paged'] && $wp_query->current_post == ( 2 ) ) || ( $wp_query->query_vars['paged'] && 0 == $wp_query->current_post ) ) |
|
echo '<div class="teasers">'; |
|
} |
|
|
|
/** |
|
* Teaser Divider |
|
* |
|
*/ |
|
function be_teaser_divider() { |
|
if( in_array( 'last', get_post_class() ) || in_array( 'right', get_post_class() ) ) |
|
echo '<div class="teaser-divider"></div>'; |
|
} |
|
|
|
/** |
|
* Teaser Close |
|
* |
|
*/ |
|
function be_teaser_close() { |
|
if( in_array( 'last', get_post_class() ) ) |
|
echo '</div><!-- .teasers -->'; |
|
} |
|
|
|
|
|
/** |
|
* Customize Read More Link |
|
* @author Bill Erickson |
|
* @link http://www.billerickson.net/read-more-link |
|
* |
|
* @param string |
|
* @return string |
|
*/ |
|
function be_more_link($more_link) { |
|
return sprintf('</p><p><a href="%s" class="more-link">%s</a></span>', get_permalink(), 'Read More'); |
|
} |
|
|
|
/** |
|
* Archive Post Info |
|
* |
|
*/ |
|
function be_archive_post_info( $post_info ) { |
|
if( in_array( 'teaser', get_post_class() ) ) |
|
$post_info .= '<br />[post_comments zero="Comments (0)" one="Comments (1)" more="Comments (%)"]'; |
|
|
|
return $post_info; |
|
} |
|
|
|
/** |
|
* Shorten Excerpts for Teasers |
|
* |
|
*/ |
|
function be_shorten_excerpt_for_teasers( $length ) { |
|
if( in_array( 'teaser', get_post_class() ) ) |
|
$length = 150; |
|
|
|
return $length; |
|
} |
|
|
|
/** |
|
* Archive Post Meta |
|
* |
|
*/ |
|
function be_archive_post_meta( $post_meta ) { |
|
if( in_array( 'teaser', get_post_class() ) ) |
|
$post_meta = '[post_tags before="Tags: "]'; |
|
|
|
return $post_meta; |
|
} |
|
|
|
genesis(); |