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.

Leave a Comment