Is there any way to use get_template_part() with folders?

In fact you can, I have a folder in my theme directory called /partials/ in in that folder I have files such as latest-articles.php, latest-news.php and latest-statements.php and I load these files using get_template_part() like: get_template_part(‘partials/latest’, ‘news’); get_template_part(‘partials/latest’, ‘articles’); get_template_part(‘partials/latest’, ‘statements’); Just dont forget to omit the .php from the file name.

Passing variables through locate_template

Like MathSmath wrote, get_template() does not support the re-use of your variables. But locate_template() infact does no inclusion at all. It just locates a file for inclusion. So you can make use of include to have this working just like you expect it: include(locate_template(‘custom-template-part.php’)); $var from your example can be used in the template part … Read more