Created
February 15, 2012 22:51
-
-
Save destos/1839779 to your computer and use it in GitHub Desktop.
get_post_type_template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function get_post_type_template( $context = null ) { | |
| $type = (string) get_post_type( get_the_ID() ); | |
| $format = (string) get_post_format( get_the_ID() ); | |
| do_action( "get_post_type_template_{$type}", $format, $context ); | |
| $templates = array(); | |
| if ( !empty($format) ){ | |
| if(is_array($context)){ | |
| foreach($context as $con) | |
| $templates[] = "type-{$type}-{$format}-{$con}.php"; | |
| }else{ | |
| $templates[] = "type-{$type}-{$format}-{$context}.php"; | |
| } | |
| $templates[] = "type-{$type}-{$format}.php"; | |
| } | |
| if(is_array($context)){ | |
| foreach($context as $con) | |
| $templates[] = "type-{$type}-{$con}.php"; | |
| }else{ | |
| $templates[] = "type-{$type}-{$context}.php"; | |
| } | |
| $templates[] = "type-{$type}.php"; | |
| locate_template( $templates, true, false ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment