[wp-trac] [WordPress Trac] #18151: Option to return string false for locate_template()
WordPress Trac
wp-trac at lists.automattic.com
Mon Jul 18 03:21:06 UTC 2011
#18151: Option to return string false for locate_template()
-------------------------+-----------------------------
Reporter: griffinjt | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Template | Version: 3.2.1
Severity: normal | Keywords: needs-patch
-------------------------+-----------------------------
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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18151>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list