Need help understanding custom templates (question)
-
I found this code in the codex where it loads a custom template depending on the post type. Link
<?php function get_custom_post_type_template($single_template) { global $post; if ($post->post_type == 'my_post_type') { $single_template = dirname( __FILE__ ) . '/post-type-template.php'; } return $single_template; } add_filter( "single_template", "get_custom_post_type_template" ) ; ?>
my question is, in the get_custom_post_type_template() function, what does the parameter $single_template do? I can see that it returns the absolute path of the template file, but why put it as a parameter when you’re going to reassign the value again, and if the $single_template isn’t assigned to the PATH then what does it return? a blank string?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Need help understanding custom templates (question)’ is closed to new replies.