I’m wondering if there is any way to use get_template_part() with folders? My main folder has a lot of files now because I put every re-usable element in a separate file. I’d like to put them in folders then.
There is no information about that in Codex: http://codex.wordpress.org/Function_Reference/get_template_part
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.