Wizard
Wizard

Reputation: 11295

WordPress image url

$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?

Upvotes: 1

Views: 79

Answers (4)

Ehsan
Ehsan

Reputation: 2285

You must use template_directory instead of template_url

<?php get_bloginfo('template_directory').'image.jpg'; ?>

Upvotes: 1

Aaron Jones
Aaron Jones

Reputation: 183

Bloginfo() always prints a result to the browser. If you need the values for use in PHP, try get_bloginfo() instead.

Upvotes: 1

vstm
vstm

Reputation: 12537

Yes bloginfo automatically displays the property (while returning null). I think you want to use get_bloginfo:

$path = get_bloginfo('stylesheet_directory');
$image_url = $path.'image.jpg';

Upvotes: 2

Dan
Dan

Reputation: 560

You need get_bloginfo() I believe.

Upvotes: 1

Related Questions