[wp-hackers] Bug in get_bloginfo('template_url') w/child themes, or am I doing it wrong?
Glenn Ansley
glenn at glennansley.com
Wed Mar 10 02:36:40 UTC 2010
I ran into this earlier this week and was pleasantly surprised with
how it works. In general, I've found that template_xxx refers to
parents and stylesheet_xxx refers to children.
add_action('template_redirect','testers',1);
function testers(){
echo "Parent ".TEMPLATEPATH."<br />";
echo "Child ".STYLESHEETPATH."<br />";
echo "Child ".get_bloginfo('stylesheet_directory')."<br />";
echo "Parent ".get_bloginfo('template_directory')."<br />";
echo "Parent ".get_bloginfo('template_url')."<br />";
echo "Child ".get_bloginfo('stylesheet_url')."<br />";
}
Glenn Ansley
http://fullthrottledevelopment.com
http://twitter.com/glennansley
On Tue, Mar 9, 2010 at 9:03 PM, Mike Schinkel
<mikeschinkel at newclarity.net> wrote:
> I'm wondering if there is a bug in get_bloginfo('template_url') with child themes, or am I doing it wrong?
>
> The following code sets $template_url to the parent's URL and not the child theme's URL:
>
> add_action('init', 'tboc_jquery_scripts');
> function tboc_jquery_scripts() {
> wp_enqueue_script('jquery');
> $template_url = get_bloginfo('template_url');
> wp_enqueue_script('tboc_scripts',"$template_url/includes/scripts.js",array('jquery'),'1.0',false);
> }
>
> Is this a bug or am I doing this wrong?
>
> Additionally shouldn't there be a way to explicitly reference the parent URL and the child URLs (there probably is, I just don't see it)?
>
> Also, what's the philosophy behind those references in general; when not explicitly specified which should be assumed (parent or child) and how does that keep from causing problems in plugins if the plugins refer to themes but don't know which they are using?
>
> FYI, I was able to override for what I'm working using this but I fear that there are cases where this will fail.
>
> add_action('template_directory_uri', 'tboc_template_directory_uri');
> function tboc_template_directory_uri($template) {
> $template = str_replace('/twentyten','/thebusinessof',$template);
> return $template;
> }
>
> Thanks for considering these issues.
>
> -Mike
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list