Portfolio in Genesis with Featured Images in a Grid revealing Title and Excerpt on Hover. http://sridharkatakam.com/portfolio-genesis-featured-images-grid-revealing-title-excerpt-hover/
/* Portfolio Archive with Featured Images in a Grid revealing Title and Excerpt on Hover
---------------------------------------------------------------------------------------- */
.portfolio-entries {
overflow: hidden;
margin-bottom: 80px;
}
.portfolio-entries .entry {
position: relative;
background: #333;
border-bottom: none;
padding-bottom: 0;
margin-bottom: 2.564102564102564%;
}
.portfolio-entries .entry-content-wrap {
padding: 30px 30px 0;
}
.content .portfolio-entries .entry:last-of-type {
margin: 0 0 2.564102564102564% 2.564102564102564%;
}
.content .portfolio-entries .entry.first:last-of-type {
margin: 0 0 2.564102564102564% 0;
}
.portfolio-entries .entry-title {
font-size: 20px;
margin-bottom: 10px;
}
.portfolio-entries .entry a {
color: #b8e3b4;
}
.portfolio-entries .entry a:hover {
color: #cff0cc;
}
.portfolio-entries .entry-content p {
margin-bottom: 0;
color: #fff;
font-size: 15px;
}
.portfolio-entries .entry img {
display: block;
left: 0;
position: absolute;
-webkit-transition: all .2s linear;
-moz-transition: all .2s linear;
-o-transition: all .2s linear;
transition: all .2s linear;
}
.portfolio-entries .entry img:hover {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)";
filter: alpha(opacity=10);
-moz-opacity: 0.1;
-khtml-opacity: 0.1;
opacity: 0.1;
}
@media only screen and (max-width: 1024px) {
.portfolio-entries .entry img {
position: static;
}
.portfolio-entries .entry-content-wrap {
padding: 30px;
}
.portfolio-entries .entry img:hover {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=1);
-moz-opacity: 1;
-khtml-opacity: 1;
opacity: 1;
}
.portfolio-entries .entry-title {
margin-bottom: 20px;
}
}
@media only screen and (max-width: 768px) {
.portfolio-entries .entry {
margin-bottom: 5%;
}
}
jQuery(function( $ ){
// equal heights
function equalHeights() {
var $col = $('.portfolio-entries > *'),
maxHeight = [],
rows = [],
rowTop = 0,
rowIndex = 0;
$col.each(function() {
$el = $(this);
$el.css('height', '');
if ($el.offset().top > rowTop) {
rowIndex++;
rows[rowIndex] = [];
rowTop = $el.offset().top;
maxHeight[rowIndex] = 0;
}
if ($el.height() > maxHeight[rowIndex]) {
maxHeight[rowIndex] = $el.height();
}
rows[rowIndex].push($el);
});
for (row = 1; row <= rowIndex; row++) {
for (i = 0; i <= rows[row].length; i++) {
$(rows[row][i]).height(maxHeight[row]);
}
}
}
// $(window).on('resize load', equalHeights);
function setHeights() {
$('.beautiful-pro-portfolio .entry').each(function() {
var $imgh = $('.beautiful-pro-portfolio .entry img').height();
$(this).css('min-height', $imgh);
});
}
$(window).on('resize load', setHeights);
});
<?php
//* Do NOT include the opening php tag
//* Add Archive Settings option to Portolio CPT
add_post_type_support( 'portfolio', 'genesis-cpt-archives-settings' );
//* Define custom image size for Portfolio images in Portfolio archive
add_image_size( 'portfolio-image', 691, 460, true );
/**
* Portfolio Template for Taxonomies
*
*/
function be_portfolio_template( $template ) {
if( is_tax( array( 'portfolio_category', 'portfolio_tag' ) ) )
$template = get_query_template( 'archive-portfolio' );
return $template;
}
add_filter( 'template_include', 'be_portfolio_template' );
add_action( 'pre_get_posts', 'be_change_portfolio_posts_per_page' );
/**
* Change Posts Per Page for Portfolio Archive
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
* @param object $query data
*
*/
function be_change_portfolio_posts_per_page( $query ) {
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
$query->set( 'posts_per_page', '10' );
}
}
<?php
/**
* Portfolio Archive
* Author: Sridhar Katakam
*
*/
//* Add portfolio body class to the head
add_filter( 'body_class', 'sk_add_portfolio_body_class' );
function sk_add_portfolio_body_class( $classes ) {
$classes[] = 'beautiful-pro-portfolio';
return $classes;
}
//* Enqueue Script
add_action( 'wp_enqueue_scripts', 'load_portfolio_script' );
function load_portfolio_script() {
wp_enqueue_script( 'portfolio-archive', get_stylesheet_directory_uri() .'/js/portfolio-archive.js' , array( 'jquery' ), '1.0.0', true );
}
//* Force full width content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
/**
* Display as Columns
*
*/
function be_portfolio_post_class( $classes ) {
global $wp_query;
if( !$wp_query->is_main_query() )
return $classes;
$columns = 3;
$column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
$classes[] = $column_classes[$columns];
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
$classes[] = 'first';
return $classes;
}
add_filter( 'post_class', 'be_portfolio_post_class' );
//* Remove items from loop
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
//* Do not show Featured image if set in Theme Settings > Content Archives
add_filter( 'genesis_pre_get_option_content_archive_thumbnail', '__return_false' );
add_action( 'genesis_entry_header', 'be_portfolio_image', 4 );
/**
* Add Portfolio Image
*
*/
function be_portfolio_image() {
echo '<a href="' . get_permalink() . '">' . genesis_get_image( array( 'size' => 'portfolio-image' ) ). '</a>';
}
//* 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>';
}
//* Wrap .entry-header and .entry-content in a custom div - opening
add_action( 'genesis_entry_header', 'sk_opening_div', 4 );
function sk_opening_div() {
echo '<div class="entry-content-wrap">';
}
//* Wrap .entry-header and .entry-content in a custom div - closing
add_action( 'genesis_entry_footer', 'sk_closing_div' );
function sk_closing_div() {
echo '</div>';
}
//* Wrap all entries in a custom div - opening
add_action( 'genesis_before_loop', 'portfolio_entries_opening' );
function portfolio_entries_opening() {
echo '<div class="portfolio-entries">';
}
//* Wrap all entries in a custom div - closing
add_action( 'genesis_after_loop', 'portfolio_entries_closing' );
function portfolio_entries_closing() {
echo '</div>';
}
genesis();