1
$path = bloginfo('template_url');
$image_url = $path.'image.jpg';

I do not know why, but $path = bloginfo('stylesheet_directory'); is displaying url without echo, any ideas where the problem is?

4

4 回答 4

2

Yesbloginfo自动显示属性(同时返回 null)。我想你想使用get_bloginfo

$path = get_bloginfo('stylesheet_directory');
$image_url = $path.'image.jpg';
于 2012-10-09T15:32:38.317 回答
1

You need get_bloginfo() I believe.

于 2012-10-09T15:32:21.487 回答
1

Bloginfo()总是将结果打印到浏览器。如果您需要在 PHP 中使用的值,请尝试使用get_bloginfo()

于 2012-10-09T15:33:26.577 回答
1

您必须使用template_directory而不是template_url

<?php get_bloginfo('template_directory').'image.jpg'; ?>
于 2012-10-09T17:12:16.673 回答