Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created June 15, 2012 21:18
Show Gist options
  • Select an option

  • Save billerickson/2938755 to your computer and use it in GitHub Desktop.

Select an option

Save billerickson/2938755 to your computer and use it in GitHub Desktop.
<?php
/**
* Blog Archive
*
* @package BE_Genesis_Child
* @since 1.0.0
* @link https://github.com/billerickson/BE-Genesis-Child
* @author Bill Erickson <bill@billerickson.net>
* @copyright Copyright (c) 2011, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
/**
* Archive Body Class
*
* @param array $classes
* @return array
*/
function be_archive_body_class( $classes ) {
$classes[] = 'archive-template';
return $classes;
}
add_filter( 'body_class', 'be_archive_body_class' );
/**
* Archive Post Class
* @since 1.0.0
*
* Breaks the posts into two columns
* @link http://www.billerickson.net/code/grid-loop-using-post-class
*
* @param array $classes
* @return array
*/
function be_archive_post_class( $classes ) {
global $wp_query;
if( in_array( $wp_query->current_post, array( 0, 1 ) ) && !$wp_query->is_paged )
$classes[] = 'feature';
else {
$classes[] = 'one-half';
if( 0 == $wp_query->current_post % 2 )
$classes[] = 'first';
}
return $classes;
}
add_filter( 'post_class', 'be_archive_post_class' );
/**
* Archive Post Image
*
*/
function be_archive_post_image() {
global $post;
$image_size = in_array( 'feature', get_post_class() ) ? 'be_full' : 'be_thumbnail';
if( has_post_thumbnail() )
echo '<p class="featured-image"><a href="' . get_permalink() . '">' . get_the_post_thumbnail( $post->ID, $image_size ) . '</a></p>';
}
add_action( 'genesis_before_post_content', 'be_archive_post_image' );
/**
* Continue Reading
*
*/
function be_archive_continue_reading() {
echo '<p class="read-more"><a class="blue-button" href="' . get_permalink() . '">Continue Reading</a></p>';
}
add_action( 'genesis_after_post_content', 'be_archive_continue_reading' );
/**
* Archive Grid Divider
*
*/
function be_grid_divider() {
if( in_array( 'one-half', get_post_class() ) && !in_array( 'first', get_post_class() ) )
echo '<div class="grid-divider"></div>';
}
add_action( 'genesis_after_post', 'be_grid_divider' );
genesis();
<?php
// ** Removed all that wasn't necessary **
/**
* Blog Archive Template
*
* @param string $template
* @return string
*/
function be_blog_archive_template( $template ) {
if( is_home() || is_archive() || is_search() )
$template = get_query_template( 'archive' );
return $template;
}
add_filter( 'template_include', 'be_blog_archive_template' );
/**
* Modify Home Query
*
* @param object $query
*/
function be_modify_home_query( $query ) {
if( $query->is_main_query() && ( $query->is_home() || $query->is_archive() || $query->is_search() ) && !is_admin() )
$query->set( 'posts_per_page', 8 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment