Template parts have to follow a specific naming pattern when using get_template_part(), while locate_template() isn't concerned with the template names. For instance, it might be necessary to use a convention similar to the WordPress Template Hierarchy:
category-slug.php
category-id.php
archive.php
index.php
Another application that can't be achieved with get_template_part() is searching for templates that don't use a .php extension.
Template parts have to follow a specific naming pattern when using
get_template_part()
, whilelocate_template()
isn't concerned with the template names. For instance, it might be necessary to use a convention similar to the WordPress Template Hierarchy:Another application that can't be achieved with
get_template_part()
is searching for templates that don't use a.php
extension.