Skip to content

Instantly share code, notes, and snippets.

@paaljoachim
Last active August 23, 2016 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paaljoachim/4e9ca3489dbdd6ba3f4d to your computer and use it in GitHub Desktop.
Save paaljoachim/4e9ca3489dbdd6ba3f4d to your computer and use it in GitHub Desktop.
Custom Post Type - used in Minimum Pro Genesis Child Theme
//* Custom Post type code used inside the functions.php file inside the Minumum Pro Genesis child theme.
//* Create portfolio custom post type
add_action( 'init', 'minimum_portfolio_post_type' );
function minimum_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'minimum' ),
'singular_name' => __( 'Portfolio', 'minimum' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-admin-page',
'public' => true,
'rewrite' => array( 'slug' => 'portfolio', 'with_front' => false ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes', 'genesis-seo' ),
)
);
}
<?php
/**
* The custom portfolio post type archive template
*/
//* Force full width content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Add even/odd post class
add_filter( 'post_class', 'minimum_even_odd_portfolio_post_class' );
function minimum_even_odd_portfolio_post_class( $classes ) {
global $wp_query;
$classes[] = ($wp_query->current_post % 2 == 0) ? 'portfolio-odd' : 'portfolio-even';
return $classes;
}
//* 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 after post title
add_action( 'genesis_entry_content', 'minimum_portfolio_grid' );
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
/**
* 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 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 author box on single posts
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
//* 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 );
//* Remove the comments template
remove_action( 'genesis_after_entry', 'genesis_get_comments_template' );
//* Run the Genesis loop
genesis();
//* CSS code that mentions the word portfolio used inside the style.css file inside the Genesis Minumum Pro child theme.
/* Titles
--------------------------------------------- */
.single-portfolio .entry-title {
margin-bottom: 20px;
}
/* Entries
--------------------------------------------- */
.post-type-archive-portfolio .entry {
float: left;
margin-bottom: 60px;
width: 50%;
}
.post-type-archive-portfolio .entry:nth-of-type(2n) {
float: right;
padding-left: 30px;
}
.post-type-archive-portfolio .entry:nth-of-type(2n+1) {
clear: left;
padding-right: 30px;
}
.single-portfolio .entry {
text-align: center;
}
@media only screen and (max-width: 1023px) {
.post-type-archive-portfolio .entry,
.site-header .title-area,
.site-header .search-form,
.site-header .widget-area,
.site-tagline-left,
.site-tagline-right {
text-align: center;
}
}
@media only screen and (max-width: 768px) {
.genesis-grid-even,
.genesis-grid-odd,
.post-type-archive-portfolio .entry {
width: 100%;
}
.post-type-archive-portfolio .entry:nth-of-type(2n),
.post-type-archive-portfolio .entry:nth-of-type(2n+1) {
float: none;
padding: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment