-
-
Save srikat/12425da9954f5a5d758a to your computer and use it in GitHub Desktop.
Filterable Portfolio Grid in Centric Pro with Title and Excerpt appearing on Hover.
This file contains 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 | |
/** | |
* This file adds the custom portfolio post type archive template to the Centric Pro Theme. | |
* | |
*/ | |
// Load Isotope | |
wp_enqueue_script('isotope', get_stylesheet_directory_uri() . '/js/jquery.isotope.min.js', array('jquery'), '', true); | |
wp_enqueue_script('isotope_init', get_stylesheet_directory_uri() . '/js/isotope_init.js', array('isotope'), '1.0.0', true); | |
// Load JS that sets the height of each grid item to that of the image in it | |
wp_enqueue_script( 'portfolio-archive', get_stylesheet_directory_uri() .'/js/portfolio-archive.js' , array( 'jquery' ), '1.0.0', true ); | |
// Force full width content layout | |
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' ); | |
// Remove the breadcrumb navigation | |
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' ); | |
// Remove post info function | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
// Remove the entry title (requires HTML5 theme support) | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
add_action( 'genesis_entry_content', 'genesis_do_post_title', 7 ); | |
// Remove entry header markup | |
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); | |
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 ); | |
// Force Excerpts | |
add_filter( 'genesis_pre_get_option_content_archive', 'sk_show_excerpts' ); | |
function sk_show_excerpts() { | |
return 'excerpts'; | |
} | |
// Modify the length of post excerpts | |
add_filter( 'excerpt_length', 'sp_excerpt_length' ); | |
function sp_excerpt_length( $length ) { | |
return 10; // pull first 10 words | |
} | |
// Modify the Excerpt read more link | |
add_filter( 'excerpt_more', 'new_excerpt_more' ); | |
function new_excerpt_more( $more ) { | |
return '... <a href="' . get_permalink() . '">More</a>'; | |
} | |
// Remove the post image | |
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); | |
// Add portfolio body class | |
add_filter( 'body_class', 'centric_add_portfolio_body_class' ); | |
function centric_add_portfolio_body_class( $classes ) { | |
$classes[] = 'centric-pro-portfolio'; | |
return $classes; | |
} | |
// Display Portfolio Categories | |
add_action( 'genesis_before_loop', 'sk_isotope_filter' ); | |
function sk_isotope_filter() { | |
if ( is_post_type_archive( 'portfolio' ) ) | |
$terms = get_terms( 'portfolio_category' ); | |
$count = count( $terms ); $i=0; | |
if ( $count > 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 } | |
} | |
// Wrap Portfolio items in a custom div - opening | |
add_action('genesis_before_loop', 'portfolio_content_opening_div' ); | |
function portfolio_content_opening_div() { | |
echo '<div class="portfolio-content">'; | |
} | |
// Add featured image in entry header | |
add_action( 'genesis_entry_header', 'centric_portfolio_grid' ); | |
function centric_portfolio_grid() { | |
if ( $image = genesis_get_image( 'format=url&size=portfolio' ) ) { | |
printf( '<div class="portfolio-featured-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) ); | |
} | |
} | |
// Add category names in post class | |
add_filter( 'post_class', 'portfolio_category_class' ); | |
function portfolio_category_class( $classes ) { | |
$terms = get_the_terms( get_the_ID(), 'portfolio_category' ); | |
if( $terms ) foreach ( $terms as $term ) | |
$classes[] = $term->slug; | |
return $classes; | |
} | |
// Wrap Portfolio items in a custom div - closing | |
add_action('genesis_after_loop', 'portfolio_content_closing_div' ); | |
function portfolio_content_closing_div() { | |
echo '</div>'; | |
} | |
// Remove post meta function | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
// Reposition Post Navigation (Previous / Next or Numeric) | |
remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' ); | |
add_action( 'genesis_after_content', 'genesis_posts_nav' ); | |
genesis(); |
This file contains 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
jQuery(function($){ | |
$(window).load(function() { | |
/*main function*/ | |
function PortfolioIsotope() { | |
var $container = $('.portfolio-content'); | |
$container.imagesLoaded(function(){ | |
$container.isotope({ | |
itemSelector: '.centric-pro-portfolio .portfolio-content .entry' | |
}); | |
}); | |
} PortfolioIsotope(); | |
/*filter*/ | |
$('.filter a').click(function(){ | |
var selector = $(this).attr('data-filter'); | |
$('.portfolio-content').isotope({ filter: selector }); | |
$(this).parents('ul').find('a').removeClass('active'); | |
$(this).addClass('active'); | |
return false; | |
}); | |
/*resize*/ | |
var isIE8 = $.browser.msie && +$.browser.version === 8; | |
if (isIE8) { | |
document.body.onresize = function () { | |
PortfolioIsotope(); | |
}; | |
} else { | |
$(window).resize(function () { | |
PortfolioIsotope(); | |
}); | |
} | |
// Orientation change | |
window.addEventListener("orientationchange", function() { | |
PortfolioIsotope(); | |
}); | |
}); | |
}); |
This file contains 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
jQuery(function( $ ){ | |
function setHeights() { | |
$('.centric-pro-portfolio .portfolio-content .entry').each(function() { | |
var $imgh = $('.centric-pro-portfolio .portfolio-content .entry img').height(); | |
$(this).css('min-height', $imgh); | |
}); | |
} | |
$(window).on('resize load', setHeights); | |
}); |
This file contains 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
/* Filterable Portfolio Grid | |
-------------------------------- */ | |
.cpt-archive-description { | |
margin-bottom: 50px; | |
} | |
.centric-pro-portfolio .site-inner { | |
background: #eee; | |
} | |
.centric-pro-portfolio .site-inner .wrap { | |
max-width: 1140px; | |
} | |
.portfolio-content { | |
margin-left: -50px; | |
margin-top: 20px; | |
} | |
.portfolio-content .entry { | |
width: 346px; | |
margin-left: 50px; | |
margin-bottom: 50px; | |
background: #333; | |
position: relative; | |
} | |
.portfolio-content .entry .entry-title { | |
padding: 25px 0 25px 20px; | |
font-size: 20px; | |
font-weight: normal; | |
margin-bottom: 0; | |
} | |
.portfolio-featured-image a { | |
display: block; | |
position: relative; | |
} | |
.portfolio-featured-image img { | |
vertical-align: top; | |
display: block; | |
position: absolute; | |
left: 0; | |
-webkit-transition: all .2s linear; | |
-moz-transition: all .2s linear; | |
-o-transition: all .2s linear; | |
transition: all .2s linear; | |
} | |
.portfolio-featured-image img:hover { | |
opacity: 0.1; | |
} | |
.portfolio-content .entry .entry-title { | |
padding: 0 0 30px 0; | |
} | |
.portfolio-content .entry-content { | |
padding: 30px; | |
} | |
.portfolio-content .entry-content .entry-title a, | |
.portfolio-content .entry-content p { | |
color: #fff; | |
} | |
.prev-next-post-links { | |
overflow: hidden; | |
} | |
.previous-post-link { | |
float: left; | |
} | |
.next-post-link { | |
float: right; | |
} | |
.portfolio-image-single { | |
text-align: center; | |
margin-top: 10px; | |
margin-bottom: 30px; | |
} | |
.taxonomy-title { | |
margin-top: 30px; | |
margin-bottom: 30px; | |
} | |
/* | |
Filterable Portfolio | |
------------------------ */ | |
ul.filter { | |
color: #999; | |
list-style: none; | |
margin-left: 0; | |
} | |
ul.filter li { | |
float: left; | |
margin-left: 1rem; | |
margin-left: 10px; | |
margin-bottom: 1rem; | |
margin-bottom: 10px; | |
} | |
ul.filter li:first-child { | |
margin-left: 0; | |
} | |
ul.filter a { | |
background: #333; | |
color: #fff; | |
display: block; | |
padding: 0.5rem 1rem; | |
text-decoration: none; | |
border-bottom: none; | |
} | |
ul.filter a:hover, ul.filter a.active { | |
background: #2bb7e2; | |
} | |
.isotope-item { | |
z-index: 2; | |
} | |
.isotope-hidden.isotope-item { | |
pointer-events: none; | |
z-index: 1; | |
} | |
/**** Isotope CSS3 transitions ****/ | |
.isotope, | |
.isotope .isotope-item { | |
-webkit-transition-duration: 0.8s; | |
-moz-transition-duration: 0.8s; | |
-ms-transition-duration: 0.8s; | |
-o-transition-duration: 0.8s; | |
transition-duration: 0.8s; | |
} | |
.isotope { | |
-webkit-transition-property: height, width; | |
-moz-transition-property: height, width; | |
-ms-transition-property: height, width; | |
-o-transition-property: height, width; | |
transition-property: height, width; | |
} | |
.isotope .isotope-item { | |
-webkit-transition-property: -webkit-transform, opacity; | |
-moz-transition-property: -moz-transform, opacity; | |
-ms-transition-property: -ms-transform, opacity; | |
-o-transition-property: -o-transform, opacity; | |
transition-property: transform, opacity; | |
} | |
/**** disabling Isotope CSS3 transitions ****/ | |
.isotope.no-transition, | |
.isotope.no-transition .isotope-item, | |
.isotope .isotope-item.no-transition { | |
-webkit-transition-duration: 0s; | |
-moz-transition-duration: 0s; | |
-ms-transition-duration: 0s; | |
-o-transition-duration: 0s; | |
transition-duration: 0s; | |
} | |
@media only screen and (max-width: 1220px) { | |
.centric-pro-portfolio .content { | |
padding-left: 2%; | |
padding-right: 2%; | |
} | |
} | |
@media only screen and (max-width: 1024px) { | |
.portfolio-featured-image img { | |
position: static; | |
} | |
.portfolio-featured-image img:hover { | |
opacity: 1; | |
} | |
.centric-pro-portfolio .entry { | |
width: 290px; | |
} | |
} | |
@media only screen and (max-width: 768px) { | |
.portfolio-content { | |
margin-left: -20px; | |
} | |
.centric-pro-portfolio .entry { | |
width: 320px; | |
margin-left: 20px; | |
margin-bottom: 20px; | |
} | |
} | |
@media only screen and (max-width: 568px) { | |
.centric-pro-portfolio .entry { | |
width: 230px; | |
} | |
} | |
@media only screen and (max-width: 488px) { | |
.portfolio-content { | |
margin-left: 0; | |
} | |
.centric-pro-portfolio .entry { | |
width: 346px; | |
margin-left: 0; | |
margin-bottom: 20px; | |
} | |
} | |
@media only screen and (max-width: 320px) { | |
.centric-pro-portfolio .entry { | |
width: 300px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://sridharkatakam.com/filterable-portfolio-grid-in-altitude-pro-with-title-and-excerpt-appearing-on-hover/#comment-391579