Template parts are a fundamental part of building WordPress themes but sometimes it can be difficult to find out why a given template part is or isn’t loading.
The latest version of Query Monitor makes debugging template part loading easier by exposing the list of any template parts that were not loaded, in addition to those that were. Here’s a screenshot of it in action:
What this allows you to do is to see the value of the
$name parameters that were passed to
get_template_part() when an unsuccessful request for a template part was made. Query Monitor will show you the file name and line number where the call was made, so you can find it easily and investigate if necessary, or if you’ve got clickable stack traces enabled you can just click it to be taken straight there.
Note that this feature requires WordPress 5.2 or later, as it uses a new hook that was introduced in that version.
I hope this feature is useful to you! I’ve certainly been finding it useful myself.