Snippets: Easy Custom Post Type Entry Override

Allows you to create your own file in your child theme for your custom post type entries. You can use this method for any post type archive or custom taxonomies defined via a Custom post types plugin such as the "Custom Post Types UI Plugin" (recommended) or defined via your child theme. While you can override your entries via the files at partials/cpt/ this method is much cleaner and if you are familiar with WP code it allows more freedom.

function myprefix_custom_template_parts( $parts ) {

	// Override the output for your 'books' post type
	// Now you can simply create a book-entry.php file in your child theme
	// and whatever you place there will display for the entry
	if ( 'books' == get_post_type() ) {
		$parts['cpt_entry'] = 'book-entry';
	}

	// Return parts
	return $parts;

}
add_filter( 'wpex_template_parts', 'myprefix_custom_template_parts' );
All PHP snippets should be added via a child theme's functions.php file.