Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active April 23, 2019 07:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save srikat/9306911 to your computer and use it in GitHub Desktop.
Save srikat/9306911 to your computer and use it in GitHub Desktop.
Staff Custom Post Type Grid in Genesis. http://sridharkatakam.com/staff-custom-post-type-grid-genesis/
<?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;
}
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" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
echo '<div class="title-meta">';
genesis_do_post_title();
genesis_post_meta();
echo '</div>';
}
}
//* Remove the post meta function
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
genesis();
//* Add new image size
add_image_size( 'staff', 326, 427, true );
// Width = [container's width - (number of columns - 1)xgap] / number of columns
// Height = can be any value of your choice
//* Show Staff Type custom taxonomy terms and tags
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;
}
[wpv-view name="Staff Grid"]
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
<div class="staff-profile">
<div class="staff-featured-image">
<a href="[wpv-post-url]" rel="bookmark">[wpv-post-featured-image size="staff"]</a>
</div>
<div class="title-meta">
<h1 class="entry-title" itemprop="headline">
<a href="[wpv-post-url]" title="[wpv-post-title]" rel="bookmark">[wpv-post-title]</a>
</h1>
<p class="entry-meta">
<span class="entry-terms">
Position: [wpv-post-taxonomy type="staff-position" separator=", " format="link" show="name" order="asc"]
</span></p>
</div>
</div>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]<strong>No items found</strong>[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
<?php
/**
* This file adds the custom portfolio 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-single"><img src="%s" alt="%s" class="alignleft" /></div>', $image, the_title_attribute( 'echo=0' ) );
}
}
genesis();
/* Staff Grid
--------------------- */
.staff-section-title {
font-size: 30px;
font-weight: bold;
margin-bottom: 30px;
}
.staff-grid-archive .entry,
.staff-profile {
float: left;
width: 30.8176100629%; /* [container's width - (number of columns - 1)xgap] / number of columns */
margin-left: 3.7735849057%; /* (gap / container's width)x100 */
margin-bottom: 40px;
}
.staff-grid-archive .entry:nth-of-type(3n+1),
.staff-profile:nth-of-type(3n+1) {
clear: left;
margin-left: 0;
}
.staff-grid-archive .content .entry-header,
.staff-profile {
position: relative;
}
.staff-featured-image {
background: #eee;
border: 1px solid #ddd;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
padding: 12px;
}
.staff-featured-image img {
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
vertical-align: top;
}
.title-meta {
background: rgba(0, 0, 0, 0.5);
padding: 20px;
-webkit-border-radius: 0px 2px 2px 2px;
-moz-border-radius: 0px 2px 2px 2px;
border-radius: 0px 2px 2px 2px;
position: absolute;
bottom: 13px;
left: 13px;
}
.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;
}
@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-featured-image {
-webkit-border-radius: 4px 4px 0px 0px;
-moz-border-radius: 4px 4px 0px 0px;
border-radius: 4px 4px 0px 0px;
}
.title-meta {
position: static;
-webkit-border-radius: 0px 0px 2px 2px;
-moz-border-radius: 0px 0px 2px 2px;
border-radius: 0px 0px 2px 2px;
}
}
@media only screen and (max-width: 568px) {
.staff-grid-archive .content p.entry-meta,
.staff-profile p.entry-meta {
line-height: 1.2;
}
.staff-grid-archive .content .entry-title,
.staff-profile .entry-title {
margin-bottom: 10px;
line-height: 1.1;
font-size: 20px;
}
}
@media only screen and (max-width: 320px) {
.staff-grid-archive .entry,
.staff-profile {
margin-left: 0;
width: 100%;
margin-bottom: 30px;
}
.staff-grid-archive .entry:last-child,
.staff-profile .entry:last-child {
margin-bottom: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment