Aren't these functions the same?
I'm sure this is simple, but I'm not able to figure out why this is not working.
If I use the first imagegif function, it works perfectly. However, when I comment that one out and try to use the second one, it fails. No error, it just does not write the image file.
imagegif($img, "../wp-content/themes/mytheme/styles/test/sidebar.gif");
imagegif($img, get_bloginfo('template_directory')."/styles/test/sidebar.gif");
Thi开发者_如何学Gos function is located in my functions.php file located in my theme directory, which is why in the hardcoded imagegif function, I'm moving the directory up one level.
Perhaps the imagegif function needs a relative path and not absolute? If so, how to convert the get_bloginfo to a relative path?
var_dump(get_bloginfo('template_directory'))
and see what it says; my guess would be it's not the path you're expecting.
TEMPLATEPATH
This returns the path to the template files of a theme. If a child theme is activated, this path will still point to the parent theme. An example path would be “/var/www/html/mysite/wp-content/themes/parenttheme”. You would most likely use this call to include a file. Example code in the functions.php file:
// Create Theme Options Page
require_once(TEMPLATEPATH . '/extensions/theme-options.php');
bloginfo(‘template_directory’);
bloginfo(‘template_directory’) returns the URL of the template directory. An example of this would be “http://mysite.com/multisite1/wp-content/themes/parenttheme”. This could be used to call a stylesheet or an image file. If a child theme is activated, this still returns the parent template directory. Example code in the header.php file:
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('template_directory'); ?>/css/ie6.css" />
<![endif]-->
Taken from Wordpress Theming: Where’s My Theme File?
精彩评论