transmitstudio
11/3/2016 - 10:49 PM

Remove Post Meta or Post Info from Custom Post Types in Genesis

Remove Post Meta or Post Info from Custom Post Types in Genesis

<?php
// remove post info, post meta, and title from a single CPT
add_action ('get_header', 'tx_remove_post_info');
function tx_remove_post_info() {
	if ('CPTNAME' == get_post_type()) {
		remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
		remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
		remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
		}
}

// or you can check for multiple CPTs by checking for an array of CPT names
add_action ('get_header', 'tx_remove_post_info');
function tx_remove_post_info() {
	if (is_singular(array( 'CPTNAME1', 'CPTNAME2', 'CPTNAME3' ))) {
		remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
		remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
		remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
		}
}
?>
<?php
/* Before we can access the CPT, we have to add a function to enable conditional, e.g.
 if (is_post_type('custom-post-type')) */
function is_post_type($type){
    global $wp_query;
    if($type == get_post_type($wp_query->post->ID)) return true;
    return false;
}

// remove post info from cpt
add_action ('get_header', 'tx_remove_post_info');
function tx_remove_post_info() {
	if (is_post_type('CPTNAME') && is_single()) {
		remove_action ('genesis_before_post_content', 'genesis_post_info');
	}
}
?>