Skip to content

Instantly share code, notes, and snippets.

@jesgs
Created November 9, 2017 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesgs/afbee9fd5a244c73353f44f7ac9439ae to your computer and use it in GitHub Desktop.
Save jesgs/afbee9fd5a244c73353f44f7ac9439ae to your computer and use it in GitHub Desktop.
<?php
/**
* Theme view template example using locate_template
*
* @return string
*/
function my_theme_template()
{
// do view related stuff
$date = date('M j Y');
$template_content = "";
$found_template = locate_template(array('my-template.php'));
if (!$found_template)
return $template_content; // return empty if not found
ob_start();
require_once $found_template;
return ob_get_clean();
}
// EOF
?>
<?php
/**
* my-template.php
*/
?>
Today's date: <?php echo $date; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment