这些功能不一样吗?

时间:2010-09-13 15:05:17

标签: image-processing

我确信这很简单,但我无法弄清楚为什么这不起作用。

如果我使用第一个imagegif函数,它可以很好地工作。但是,当我评论一个并尝试使用第二个时,它失败了。没有错误,它只是不写图像文件。

    imagegif($img, "../wp-content/themes/mytheme/styles/test/sidebar.gif");
    imagegif($img, get_bloginfo('template_directory')."/styles/test/sidebar.gif");

这个函数位于我的theme.php文件中,位于我的主题目录中,这就是为什么在硬编码的imagegif函数中,我将目录向上移动一层。

也许imagegif函数需要相对路径而不是绝对路径?如果是这样,如何将get_bloginfo转换为相对路径?

2 个答案:

答案 0 :(得分:0)

var_dump(get_bloginfo('template_directory'))并看看它的内容;我的猜测是,这不是你期待的道路。

答案 1 :(得分:0)

TEMPLATEPATH

这将返回主题模板文件的路径。如果激活了子主题,则此路径仍将指向父主题。示例路径是“/ var / www / html / mysite / wp-content / themes / parenttheme”。您很可能会使用此调用来包含文件。 functions.php文件中的示例代码:

// Create Theme Options Page
require_once(TEMPLATEPATH . '/extensions/theme-options.php');

代码bloginfo(“template_directory”);

bloginfo('template_directory')返回模板目录的URL。一个例子是“http://mysite.com/multisite1/wp-content/themes/parenttheme”。这可用于调用样式表或图像文件。如果激活了子主题,则仍会返回父模板目录。 header.php文件中的示例代码:

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('template_directory'); ?>/css/ie6.css" />
<![endif]-->

取自Wordpress Theming: Where’s My Theme File?

相关问题