$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?
Yesbloginfo自动显示属性(同时返回 null)。我想你想使用get_bloginfo:
$path = get_bloginfo('stylesheet_directory');
$image_url = $path.'image.jpg';
You need get_bloginfo() I believe.
Bloginfo()总是将结果打印到浏览器。如果您需要在 PHP 中使用的值,请尝试使用get_bloginfo()。
您必须使用template_directory而不是template_url
<?php get_bloginfo('template_directory').'image.jpg'; ?>