Last active
October 9, 2015 02:19
-
-
Save srikat/9737851 to your computer and use it in GitHub Desktop.
Staff Grid in Genesis with clickable featured images opening Excerpts in a lightbox popup. http://sridharkatakam.com/staff-grid-genesis-clickable-featured-images-opening-excerpts-lightbox-popup/
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 staff post type archive template. | |
* | |
*/ | |
//* 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 title | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
//* Remove the post info function | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
//* Remove the post content | |
remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); | |
//* Remove the post image | |
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); | |
//* Add staff-grid-archive body class | |
add_filter( 'body_class', 'sk_add_staff_body_class' ); | |
function sk_add_staff_body_class( $classes ) { | |
$classes[] = 'staff-grid-archive'; | |
return $classes; | |
} | |
/** | |
* Display as Columns | |
* | |
*/ | |
function be_portfolio_post_class( $classes ) { | |
$columns = 4; | |
$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' ); | |
add_action ('genesis_before_loop', 'sk_staff_grid_title'); | |
function sk_staff_grid_title() { | |
echo '<h1 itemprop="headline" class="staff-section-title">Staff Members</h1>'; | |
} | |
//* Featured image, post title and meta | |
add_action( 'genesis_entry_header', 'sk_staff_grid' ); | |
function sk_staff_grid() { | |
if ( $image = genesis_get_image( 'format=url&size=staff' ) ) { | |
printf( '<div class="staff-featured-image"><a href="%s" target="foobox" data-width="650px" data-height="230px" rel="bookmark"><img src="%s" alt="%s" /></a></div>', thefooboxcontent(), $image, the_title_attribute( 'echo=0' ) ); | |
echo '<div class="title-meta">'; | |
genesis_do_post_title(); | |
genesis_post_meta(); | |
echo '</div>'; | |
} | |
} | |
//* Construct the link for each featured image. Ex.: #staff-member1 for latest Staff post, #staff-member2 for the post before that and so on.. | |
function thefooboxcontent() { | |
// return '#staff-member' . get_the_ID(); | |
global $wp_query; | |
return '#staff-member' . ($wp_query->current_post + 1); | |
} | |
//* Remove the post meta function | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
add_action ( 'genesis_after_entry', 'display_foobox_content' ); | |
function display_foobox_content() { | |
// echo '<div id="staff-member' . get_the_ID() . '" style="display: none;"><div class="lightbox-content">'; genesis_do_post_title(); | |
global $wp_query; | |
echo '<div id="staff-member' . ($wp_query->current_post + 1) . '" style="display: none;"><div class="lightbox-content">'; genesis_do_post_title(); | |
echo '<p>'. get_the_excerpt() . '</p></div></div>'; | |
} | |
//* Modify the Excerpt read more link | |
add_filter('excerpt_more', 'new_excerpt_more'); | |
function new_excerpt_more($more) { | |
return '... <a class="more-link" href="' . get_permalink() . '">Read More</a>'; | |
} | |
//* Customize the previous page link | |
add_filter ( 'genesis_prev_link_text' , 'sp_previous_page_link' ); | |
function sp_previous_page_link ( $text ) { | |
return g_ent( '« ' ) . __( 'Previous Page', CHILD_DOMAIN ); | |
} | |
//* Customize the next page link | |
add_filter ( 'genesis_next_link_text' , 'sp_next_page_link' ); | |
function sp_next_page_link ( $text ) { | |
return __( 'Next Page', CHILD_DOMAIN ) . g_ent( ' » ' ); | |
} | |
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
//* Add new image size for Staff members | |
add_image_size( 'staff', 300, 400, true ); | |
//* Show Staff Type custom taxonomy terms and tags in Staff archive pages | |
add_filter( 'genesis_post_meta', 'custom_portfolio_post_meta' ); | |
function custom_portfolio_post_meta( $post_meta ) { | |
if ( is_post_type_archive( 'staff' ) || is_singular( 'staff' ) || is_tax('staff-position') ) | |
$post_meta = '[post_terms taxonomy="staff-position" before="Position: "]<br/>[post_tags before="Tagged With: "]'; | |
return $post_meta; | |
} | |
/** | |
* Template Redirect | |
* Use archive-staff.php for staff-position taxonomy archive. | |
*/ | |
add_filter( 'template_include', 'sk_template_redirect' ); | |
function sk_template_redirect( $template ) { | |
if ( is_tax( 'staff-position' ) ) | |
$template = get_query_template( 'archive-staff' ); | |
return $template; | |
} |
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 staff post type single post template. | |
* | |
*/ | |
//* 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 the post info function | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
//* Remove the author box on single posts | |
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 ); | |
//* Remove the post meta function | |
// remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
//* Add the featured image | |
add_action( 'genesis_entry_content', 'sk_show_featured_image', 9 ); | |
function sk_show_featured_image() { | |
if ( $image = genesis_get_image( 'format=url&size=staff' ) ) { | |
printf( '<div class="staff-featured-image-sigle"><img src="%s" alt="%s" class="alignleft" /></div>', $image, the_title_attribute( 'echo=0' ) ); | |
} | |
} | |
//* Previous and Next Post navigation | |
add_action('genesis_after_entry', 'sk_custom_post_nav'); | |
function sk_custom_post_nav() { | |
echo '<div class="prev-next-post-links">'; | |
previous_post_link('<div class="previous-post-link">« %link</div>', '<strong>%title</strong>' ); | |
next_post_link('<div class="next-post-link">%link »</div>', '<strong>%title</strong>' ); | |
echo '</div>'; | |
} | |
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
/* Staff Grid | |
--------------------- */ | |
.staff-section-title { | |
font-size: 30px; | |
font-weight: bold; | |
margin-bottom: 30px; | |
} | |
.staff-grid-archive .content .entry-header, | |
.staff-profile { | |
position: relative; | |
} | |
.staff-featured-image img { | |
vertical-align: top; | |
/*width: 100%;*/ | |
} | |
.title-meta { | |
background: rgba(0, 0, 0, 0.5); | |
padding: 15px; | |
position: absolute; | |
bottom: 0; | |
left: 0; | |
} | |
.staff-grid-archive .content .entry-title, | |
.staff-profile .entry-title { | |
margin-bottom: 4px; | |
line-height: 1; | |
} | |
.staff-grid-archive .content .entry-title a, | |
.staff-profile .entry-title a { | |
color: #fff; | |
} | |
.staff-grid-archive .content p.entry-meta, | |
.staff-profile p.entry-meta { | |
color: #bbb; | |
text-transform: none; | |
font-size: 13px; | |
margin-bottom: 0; | |
} | |
.staff-grid-archive .content p.entry-meta a, | |
.staff-profile p.entry-meta a { | |
color: #fff; | |
} | |
.archive-pagination { | |
clear: both; | |
} | |
.lightbox-content { | |
padding: 20px; | |
line-height: 1.4; | |
} | |
.previous-post-link { | |
float: left; | |
} | |
.next-post-link { | |
float: right; | |
} | |
.featured-content .one-half, | |
.featured-content .one-third, | |
.featured-content .one-fourth, | |
.featured-content .one-fifth, | |
.featured-content .one-sixth { | |
width: 100%; | |
float: none; | |
margin: 0; | |
} | |
@media only screen and (max-width: 1023px) { | |
.staff-grid-archive .content .entry-title, | |
.staff-profile .entry-title { | |
font-size: 25px; | |
} | |
.title-meta { | |
padding: 10px; | |
} | |
} | |
@media only screen and (max-width: 860px) { | |
.staff-grid-archive .content .entry { | |
width: 45%; | |
margin-right: 40px; | |
} | |
.staff-grid-archive .content .entry:nth-of-type(2n) { | |
margin-right: 0; | |
clear: none; | |
} | |
.title-meta { | |
position: static; | |
background: transparent; | |
} | |
.staff-grid-archive .content .entry-title a, .staff-profile .entry-title a, | |
.staff-grid-archive .content p.entry-meta a, .staff-profile p.entry-meta a { | |
color: #333; | |
} | |
.staff-grid-archive .entry { | |
margin-bottom: 30px; | |
} | |
} | |
@media only screen and (max-width: 532px) { | |
.staff-grid-archive .content .entry { | |
width: 100%; | |
margin-right: 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment