Skip to content

Instantly share code, notes, and snippets.

@paaljoachim
Last active January 21, 2019 00:26
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/0afcb453a31f8efd472e to your computer and use it in GitHub Desktop.
Save paaljoachim/0afcb453a31f8efd472e to your computer and use it in GitHub Desktop.
Custom Post Type - used in Executive Pro Genesis Child Theme
//* Custom Post type code used inside the functions.php file inside the Executive Pro Genesis child theme.
//* Create Portfolio Type custom taxonomy
add_action( 'init', 'executive_type_taxonomy' );
function executive_type_taxonomy() {
register_taxonomy( 'portfolio-type', 'portfolio',
array(
'labels' => array(
'name' => _x( 'Types', 'taxonomy general name', 'executive' ),
'add_new_item' => __( 'Add New Portfolio Type', 'executive' ),
'new_item_name' => __( 'New Portfolio Type', 'executive' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'portfolio-type', 'with_front' => false ),
'show_ui' => true,
'show_tagcloud' => false,
)
);
}
//* Create portfolio custom post type
add_action( 'init', 'executive_portfolio_post_type' );
function executive_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'executive' ),
'singular_name' => __( 'Portfolio', 'executive' ),
),
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/lib/icons/portfolio.png',
'public' => true,
'rewrite' => array( 'slug' => 'portfolio', 'with_front' => false ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
'taxonomies' => array( 'portfolio-type' ),
)
);
}
//* Add Portfolio Type Taxonomy to columns
add_filter( 'manage_taxonomies_for_portfolio_columns', 'executive_portfolio_columns' );
function executive_portfolio_columns( $taxonomies ) {
$taxonomies[] = 'portfolio-type';
return $taxonomies;
}
<?php
/**
* This file adds the custom portfolio post type archive template to the Executive Pro Theme.
*
* @author StudioPress
* @package Executive Pro
* @subpackage Customizations
*/
//* 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', 5 );
//* 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 portfolio body class to the head
add_filter( 'body_class', 'executive_add_portfolio_body_class' );
function executive_add_portfolio_body_class( $classes ) {
$classes[] = 'executive-pro-portfolio';
return $classes;
}
//* Add the featured image after post title
add_action( 'genesis_entry_header', 'executive_portfolio_grid' );
function executive_portfolio_grid() {
if ( $image = genesis_get_image( 'format=url&size=portfolio' ) ) {
printf( '<div class="portfolio-featured-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}
//* Remove the post meta function
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
genesis();
<?php
/**
* This file adds the custom portfolio post type single post template to the Executive Pro Theme.
*
* @author StudioPress
* @package Executive Pro
* @subpackage Customizations
*/
//* 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', 5 );
//* 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' );
genesis();
//* CSS code that mentions the word portfolio used inside the style.css file inside the Genesis Executive Pro child theme.
/* Content */
.executive-pro-portfolio .content {
padding: 40px 30px 0;
}
/* Titles
--------------------------------------------- */
.archive-title,
.widget-title,
.executive-pro-portfolio .entry-title {
font-size: 16px;
text-transform: uppercase;
margin-bottom: 20px;
}
/* Portfolio
--------------------------------------------- */
.executive-pro-portfolio .portfolio {
float: left;
padding: 0 30px 30px;
width: 33.33333333%;
}
.executive-pro-portfolio .portfolio:nth-of-type(3n+1) {
clear: left;
}
.single-portfolio .content {
text-align: center;
}
/* Entries
--------------------------------------------- */
.executive-pro-portfolio .entry,
.single-portfolio .entry {
margin-bottom: 20px;
}
@media only screen and (max-width: 800px) {
.five-sixths,
.footer-widgets-1,
.footer-widgets-2,
.footer-widgets-3,
.four-sixths,
.home-middle .widget,
.home-top .widget,
.one-fourth,
.one-half,
.one-sixth,
.one-third,
.executive-pro-portfolio .portfolio,
.three-fourths,
.three-sixths,
.two-fourths,
.two-sixths,
.two-thirds {
margin: 0;
width: 100%;
}
.home-middle,
.home-top,
.executive-pro-portfolio .portfolio {
text-align: center;
}
.executive-pro-portfolio .portfolio {
padding: 0 0 30px;
}
}
<?php
/**
* This file adds the portfolio type taxonomy archive template to the Executive Pro Theme.
*
* @author StudioPress
* @package Executive Pro
* @subpackage Customizations
*/
//* 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', 5 );
//* 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 portfolio body class to the head
add_filter( 'body_class', 'executive_add_portfolio_body_class' );
function executive_add_portfolio_body_class( $classes ) {
$classes[] = 'executive-pro-portfolio';
return $classes;
}
//* Add the featured image after post title
add_action( 'genesis_entry_header', 'executive_portfolio_grid' );
function executive_portfolio_grid() {
if ( $image = genesis_get_image( 'format=url&size=portfolio' ) ) {
printf( '<div class="portfolio-featured-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}
//* Remove the post meta function
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment