Last active
August 29, 2015 14:07
-
-
Save soutar/1105efff53d38eb07d91 to your computer and use it in GitHub Desktop.
get_template_part_with()
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
<?php | |
/** | |
* This function extends get_template_part to include the ability | |
* to pass variables to the template file | |
* | |
* @param $template_names array|string Either a single template name or an array of template names, ordered by priority | |
* @param $variables array The variables to make available to the template | |
*/ | |
function get_template_part_with($template_names, $variables = array()) { | |
extract($variables); | |
unset($variables); | |
if (is_array($template_names)) { | |
include locate_template($template_names); | |
} else { | |
include locate_template(array($template_names)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment