Option to return string false for locate_template()
|Reported by:||griffinjt||Owned by:|
If this is something that can be fixed without editing the core, then I apologize. :) But I've been hunting through and don't think there is a way around this.
locate_template() returns the string of the template filename if successful and nothing if empty. This is nice, but annoying if you do not want to have the filename returned on success. If you want to load the template as part of a template_redirect or the like, then you are stuck with returning the filename in a string as well, which finds itself outputted on the page where the template is called.
load_template() gets around this, but it does not provide the functionality for a child theme because it looks for the file within the parent theme. Only locate_template() (as far as I know) will search the child theme first and then parent theme. This is especially useful for those that want to override a "core" parent template without actually making a core edit.
It would be nice just to add a parameter or something of that nature that will allow you to choose if you want to have the filename returned on success or not when using locate_template(). I hope I am making sense, and if I'm not, tell me and I will try to explain better and show an example.
Change History (9)
comment:3 @griffinjt — 4 years ago
- Resolution duplicate deleted
- Status changed from closed to reopened