How to make get_template_part always check child theme first?

It does, by default. The get_template_part() function uses locate_template() which cascades through the template files in in order of specificity and stylesheetpath/templatepath.

So, if your Child Theme includes a content-inventory.php, then get_template_part() will include it; if not, then it will look for content-inventory.php in the parent Theme. If it doesn’t find it, it will then look for content.php first in the child, then in the parent.

EDIT:

Taking a stab at understanding what you mean; please clarify if I’m misunderstanding…

You want to include a new template part file within a Parent-Theme template file called content-inventory.php, right?

The only way, AFAIK, that you can do that is to copy content-inventory.php into your Child Theme, and then add the new get_template_part() call where needed.

If a file named content-inventory.php is included in both the Parent and the Child Theme, then WordPress will always use the Child Theme version, if included using get_template_part().

Leave a Comment