Oz Web Services
  • Home
  • WP
  • PHP
  • JS
  • CSS
  • SCSS
  • HTML
  • XML
  • JSON
  • SQL
  • .htaccess
  • Apache
  • Nginx
  • INI
  • HTTP
  • Diff
Search shortcode

WP: Plugins: Get Custom Post Type Template

Updated May 14, 2014
/**
 * get_template
 *
 * @since 0.1
 */
function get_custom_post_type_template( $template ) {
	global $post;
	if ( $post->post_type == 'my_post_type' ) {
		$template = dirname( __FILE__ ) . '/post-type-template.php';
	}
	return $template;
}
add_filter( 'template_include', 'get_custom_post_type_template' );

/* more filters (from http://codex.wordpress.org/Template_Hierarchy)
archive_template
author_template
category_template
tag_template
taxonomy_template
date_template
home_template
front_page_template
page_template
paged_template
search_template
single_template
attachment_template
*/
Oz Web Services
Copyright © 2015-2025 All Rights Reserved