Created
April 24, 2020 13:23
-
-
Save jesders/3a6530a1fc399245c09ab73e64db2f07 to your computer and use it in GitHub Desktop.
Setting single post template in WordPress
This file contains 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
https://codex.wordpress.org/Plugin_API/Filter_Reference/single_template | |
<?php | |
function get_custom_post_type_template( $single_template ) { | |
global $post; | |
if ( 'my_post_type' === $post->post_type ) { | |
$single_template = dirname( __FILE__ ) . '/post-type-template.php'; | |
} | |
return $single_template; | |
} | |
add_filter( 'single_template', 'get_custom_post_type_template' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment