Created
December 18, 2012 21:06
-
-
Save billerickson/4332016 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Portfolio 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 | |
* | |
*/ | |
/** | |
* Portfolio Body Class | |
* | |
* @param array $classes | |
* @return array | |
*/ | |
function be_portfolio_body_class( $classes ) { | |
$classes[] = 'portfolio-section'; | |
return $classes; | |
} | |
add_filter( 'body_class', 'be_portfolio_body_class' ); | |
/** | |
* Collect Testimonials | |
* | |
*/ | |
function be_collect_testimonials() { | |
if( have_posts() ): while( have_posts() ): the_post(); | |
global $post, $be_testimonials; | |
$testimonial = get_post_meta( $post->ID, 'be_project_testimonial', true ); | |
if( $testimonial ) { | |
$testimonial = '<div class="clearfix"></div><div class="testimonial">' . wpautop( $testimonial ); | |
$name = get_post_meta( $post->ID, 'be_project_testimonial_name', true ); | |
if( !empty( $name ) ) | |
$testimonial .= '<p class="name">-- ' . $name . '</p>'; | |
$testimonial .= '</div><div class="clearfix"></div>'; | |
$be_testimonials[] = $testimonial; | |
} | |
endwhile; endif; | |
} | |
add_action( 'genesis_before_loop', 'be_collect_testimonials' ); | |
/** | |
* Sort Projects | |
* | |
*/ | |
function be_sort_projects() { | |
echo '<div class="sort-projects">'; | |
echo '<h3><span>Sort by project type:</span></h3>'; | |
echo '<ul>'; | |
// All Projects | |
$class = is_post_type_archive( 'projects' ) ? 'all-projects active' : 'all-projects'; | |
echo '<li class="' . $class . '"><a href="' . get_post_type_archive_link( 'projects' ) . '">All<br />Projects</a></li>'; | |
// Project Types | |
$types = get_terms( 'type', array( 'orderby' => 'menu_order' ) ); | |
foreach ( $types as $type ) { | |
$class = is_tax( 'type', $type->slug ) ? $type->slug . ' active' : $type->slug; | |
echo '<li class="' . $class . '"><a href="' . get_term_link( $type, 'type' ) . '">' . $type->name . '</a></li>'; | |
} | |
echo '</ul></div>'; | |
} | |
add_action( 'genesis_before_loop', 'be_sort_projects' ); | |
// No Post Info | |
remove_action( 'genesis_before_post_title', 'genesis_post_info' ); | |
/** | |
* Project Post Classes | |
* | |
* @param array $classes | |
* @return array | |
*/ | |
function be_project_post_classes( $classes ) { | |
global $wp_query; | |
$classes[] = 'one-third'; | |
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3 ) | |
$classes[] = 'first'; | |
return $classes; | |
} | |
add_filter( 'post_class', 'be_project_post_classes' ); | |
/** | |
* Outer Wrap | |
* | |
*/ | |
function be_outer_wrap() { | |
echo '<div class="outer-wrap">'; | |
} | |
add_action( 'genesis_before_loop', 'be_outer_wrap', 80 ); | |
/** | |
* Outer Wrap Close | |
* | |
*/ | |
function be_outer_wrap_close() { | |
echo '</div>'; | |
} | |
add_action( 'genesis_after_loop', 'be_outer_wrap_close', 1 ); | |
/** | |
* Project Archive Content | |
* | |
*/ | |
function be_project_archive_content() { | |
global $post; | |
echo '<div class="image"><a href="' . get_permalink() . '">' . get_the_post_thumbnail( $post->ID, 'be_project_thumbnail' ) . '</a></div>'; | |
$terms_output = ''; | |
$terms = get_the_terms( $post->ID, 'type' ); | |
foreach( $terms as $term ) | |
$terms_output .= '<a class="icon-type ' . $term->slug . '" href="' . get_term_link( $term, 'type' ) . '">' . $term->name . '</a> '; | |
if( !empty( $terms_output ) ) | |
echo wpautop( $terms_output ); | |
} | |
add_action( 'genesis_post_content', 'be_project_archive_content' ); | |
/** | |
* Project Divider | |
* | |
*/ | |
function be_project_divider() { | |
global $wp_query; | |
$count = $wp_query->current_post + 1; | |
if( 0 == $count % 3 && $count !== 6 && $count !== $wp_query->post_count ) | |
echo '<div class="divider"></div>'; | |
} | |
add_action( 'genesis_after_post', 'be_project_divider' ); | |
/** | |
* Project Quote | |
* | |
*/ | |
function be_project_quote() { | |
global $wp_query, $be_testimonials; | |
if( !( ( 5 < $wp_query->found_posts && 5 == $wp_query->current_post ) || ( $wp_query->current_post == ( $wp_query->found_posts - 1 ) && 5 > $wp_query->found_posts ) ) ) | |
return; | |
if( isset( $be_testimonials ) && !empty( $be_testimonials ) ) { | |
$testimonial = $be_testimonials[0]; | |
if( is_tax( 'type', 'mobile-design' ) ) | |
$testimonial = $be_testimonials[2]; | |
if( is_tax( 'type', 'design-to-website' ) ) | |
$testimonial = $be_testimonials[1]; | |
echo $testimonial; | |
} else { | |
echo '<div class="divider"></div>'; | |
} | |
} | |
add_action( 'genesis_after_post', 'be_project_quote' ); | |
genesis(); |
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 | |
/** | |
* Functions | |
* | |
* @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 | |
* | |
*/ | |
/** | |
* Portfolio Query | |
* | |
* @param object $query | |
* @return null | |
*/ | |
function be_portfolio_query( $query ) { | |
if( $query->is_main_query() && !is_admin() && ( is_post_type_archive( 'projects' ) || is_tax( 'type' ) ) ) { | |
$query->set( 'posts_per_page', 18 ); | |
$query->set( 'orderby', 'menu_order' ); | |
$query->set( 'order', 'ASC' ); | |
$query->set( 'post_type', 'projects' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'be_portfolio_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment