Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srikat/0681d3eba5142620c496 to your computer and use it in GitHub Desktop.
Save srikat/0681d3eba5142620c496 to your computer and use it in GitHub Desktop.
<?php
// Force full width content
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
add_filter( 'body_class', 'sk_body_class' );
/**
* Adds a css class to the body element
*
* @param array $classes the current body classes
* @return array $classes modified classes
*/
function sk_body_class( $classes ) {
$classes[] = 'archive-portfolio';
return $classes;
}
/**
* Display as Columns
*
*/
function be_portfolio_post_class( $classes ) {
if ( is_main_query() ) { // conditional to ensure that column classes do not apply to Featured widgets
$columns = 3; // Set the number of columns here
$column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
$classes[] = $column_classes[$columns];
global $wp_query;
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 the entry title (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
// Remove post info
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
// 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 );
// Remove entry meta from entry footer incl. markup
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
// Remove the post image (requires HTML5 theme support)
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
// Display Featured image in the entry content
add_action( 'genesis_entry_content', 'sk_show_featured_image' );
function sk_show_featured_image() {
if ( $image = genesis_get_image( 'format=url&size=portfolio' ) ) {
printf( '<div class="portfolio-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}
// Remove the post content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
genesis();
// Register a custom image size for Portfolio images
add_image_size( 'portfolio', 700, 440, true );
// Add Archive Settings support to Portfolio CPT
add_post_type_support( 'portfolio', 'genesis-cpt-archives-settings' );
/* Portfolio Archive
--------------------------------------------- */
.archive-portfolio .entry {
padding: 0;
}
.archive-portfolio .entry .portfolio-image a {
display: block;
padding: 16px;
border: 1px solid rgba(0,0,0,0.1);
opacity: 0.6;
background: #fcfcfc;
-webkit-filter: grayscale(100%);
filter: grayscale(100%);
}
.archive-portfolio .entry .portfolio-image a:hover {
border: 1px solid rgba(0, 0, 0, 0.2);
opacity: 1;
background: #fff;
-webkit-filter: grayscale(0);
filter: grayscale(0);
}
@media only screen and (max-width: 800px) {
.archive-portfolio .entry {
margin-bottom: 40px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment