Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* The custom portfolio post type archive template for a Filterable Portfolio
*/
# Force full width content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
wp_enqueue_script('isotope', get_stylesheet_directory_uri() . '/js/jquery.isotope.min.js', array('jquery'), '1.5.25', true);
wp_enqueue_script('isotope_init', get_stylesheet_directory_uri() . '/js/isotope_init.js', array('isotope'), '', true);
//* Add custom body class
add_filter( 'body_class', 'filerable_portfolio_add_body_class' );
//* Filterable Portfolio custom body class
function filerable_portfolio_add_body_class( $classes ) {
$classes[] = 'filterable-portfolio-page';
return $classes;
}
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'filterable_portfolio_do_loop' );
/**
* Outputs a custom loop
*
* @global mixed $paged current page number if paginated
* @return void
*/
function filterable_portfolio_do_loop() { ?>
<header id="page-heading" class="entry-header">
<?php $terms = get_terms( 'portfolio-category' ); ?>
<?php if( $terms[0] ) { ?>
<ul id="portfolio-cats" class="filter clearfix">
<li><a href="#" class="active" data-filter="*"><span><?php _e('All', 'genesis'); ?></span></a></li>
<?php foreach ($terms as $term ) : ?>
<li><a href="#" data-filter=".<?php echo $term->slug; ?>"><span><?php echo $term->name; ?></span></a></li>
<?php endforeach; ?>
</ul><!-- /portfolio-cats -->
<?php } ?>
</header><!-- /page-heading -->
<div class="entry-content" itemprop="text">
<?php if( have_posts() ) { ?>
<div id="portfolio-wrap" class="clearfix filterable-portfolio">
<div class="portfolio-content">
<?php $wpex_count=0; ?>
<?php while( have_posts() ) : the_post() ?>
<?php $wpex_count++; ?>
<?php $terms = get_the_terms( get_the_ID(), 'portfolio-category' ); ?>
<?php if ( has_post_thumbnail($post->ID) ) { ?>
<article class="portfolio-item col-<?php echo $wpex_count; ?> <?php if( $terms ) foreach ( $terms as $term ) { echo $term->slug .' '; }; ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo genesis_get_image( array( size => 'portfolio' ) ); ?>
<div class="portfolio-overlay"><h3><?php the_title(); ?></h3></div><!-- portfolio-overlay --></a>
</article>
<?php } ?>
<?php endwhile; ?>
</div><!-- /portfolio-content -->
</div><!-- /portfolio-wrap -->
<?php } ?>
<?php wp_reset_postdata(); ?>
</div><!-- /entry-content -->
<?php }
genesis();
@srikat

This comment has been minimized.

Copy link
Owner Author

commented Dec 7, 2013

By default the number of posts will be limited to what's set in Settings > Reading. If you wish to change it, use this sample code: http://pastebin.com/raw.php?i=9xSqDJUM instead of the above. In the sample code, unlimited i.e., all posts are set to appear.

Reference: http://codex.wordpress.org/Function_Reference/query_posts#Preserving_Existing_Query_Parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.