Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Register and display Portfolio CPT
<?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' );
/** 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 );
/** Remove the post title */
remove_action('genesis_entry_header', 'genesis_do_post_title');
/** Add the featured image after post title */
add_action( 'genesis_entry_header', 'mp_portfolio_grid' );
function mp_portfolio_grid() {
if ( has_post_thumbnail() ){
echo '<div class="portfolio-featured-image">';
echo '<a href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">';
echo get_the_post_thumbnail($thumbnail->ID, 'portfolio' );
echo '</a>';
echo '</div>';
}
}
/** Remove the post meta function */
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
genesis();
/**
* Register Custom post types
*/
add_action( 'init', 'cd_post_type' );
function cd_post_type() {
// Portfolio custom post type
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio' ),
'singular_name' => __( 'Portfolio' ),
),
'has_archive' => true,
'public' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
'supports' => array( 'title', 'editor', 'genesis-seo', 'thumbnail' ),
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.