Skip to content

Instantly share code, notes, and snippets.

@mjsdiaz
Last active March 5, 2023 04:10
Show Gist options
  • Save mjsdiaz/5df1f019dc646bd1937d to your computer and use it in GitHub Desktop.
Save mjsdiaz/5df1f019dc646bd1937d to your computer and use it in GitHub Desktop.
Add Category Template for Portfolio to Genesis Modern Portfolio Pro - http://amethystwebsitedesign.com/add-category-template-for-portfolio-to-genesis-modern-portfolio-pro/
<?php
/**
* The custom template for the Design category for Modern Portfolio Pro
*/
//* Force full width content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Remove the entry meta in the entry header
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
//* Remove the entry content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
//* Remove the entry image
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
//* Add the featured image before post title
add_action( 'genesis_entry_header', 'minimum_portfolio_grid', 8 );
function minimum_portfolio_grid() {
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 entry meta in the entry footer
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 );
//* Run the Genesis loop
genesis();
<?php //Remove this and add only what's below
// Change posts per page in the design category
add_action( 'pre_get_posts', 'mp_design_cat_posts_per_page' );
function mp_design_cat_posts_per_page( $query ) {
if( $query->is_main_query() && is_category( 'design' ) && ! is_admin() ) {
$query->set( 'posts_per_page', '12' );
}
}
/* Add these styles to Modern Portfolio Pro for the category Design template */
/* Category Design Entries
--------------------------------------------- */
/* Adds the opacity and hover feature to images */
.category-design img {
margin-bottom: 16px;
margin-bottom: 1.6rem;
opacity: 0.8;
}
.category-design img:hover {
opacity: 1;
}
/* Adds the grid column width the same as the home page */
.category-design .entry {
float: left;
margin-right: 5.263157894737%; /* 60px / 1140px */
width: 29.824561403509%; /* 340px / 1140px */
}
/* Removes the right margin on the 3rd, 6th, 9th, etc. posts */
.category-design .entry:nth-of-type(3n+3) {
margin-right: 0;
}
/* Clears the float to start a new row for the 4th, 7th, etc. posts */
.category-design .entry:nth-of-type(3n+1) {
clear: left;
}
/* Smaller title size */
.category-design .entry-title {
font-size: 18px;
}
@media only screen and (max-width: 600px) {
/* Category Design Entries
--------------------------------------- */
/* Centers the posts or entries */
.category-design .entry {
text-align: center;
}
/* Removes the three across grid */
.category-design .entry,
.category-design .entry:nth-of-type(3n+3) {
float: none;
margin: 0 auto 24px;
margin: 0 auto 2.4rem;
max-width: 340px;
width: 100%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment