0

I'm having a bit of a problem with the bloginfo() function in Wordpress which I've never had before.

Normally I use <?php bloginfo('template_directory'); ?>/rest of image link here

but for some reason now it doesn't work. When I view source, it's not echoing out the link like it's supposed to and it just comes out as "src="/images/pic name here"


I've tried using get_bloginfo('stylesheet_directory');, etc.

I saw a post on SO that tried to somehow concatenate get_bloginfo() with the link like this:

<img src="'.get_bloginfo('stylesheet_directory').'/link here etc...

This didn't work either.

I'm sure I can probably hard-code it but that kind of defeats the purpose. No matter how I do it, it does not display the image, just the alt attribute text.

The weird thing is that I define my external assets the same way, like this for example:

<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/scripts_n_css/css/default.css" type="text/css" media="screen" />

Any ideas as to what's going on? Thanks in advanced.

EDIT
If you take a look at this site I'm working on, http://www.islandlivingpatio.com/?page_id=48, the images don't load up. When I inspect with FireBug, it says "failed to load given url" but it works on my localhost.

This is what the code to produce the site's image and the URL it goes to looks like:

<a href="<?php echo bloginfo('url');?>/?page_id=775"><img src="<?php bloginfo("template_directory");?>/images/Lynx.gif" alt="castandtubular"/></a>

When you click that image's alt attribute (it's the only thing showing up) then the next page also fails to load the images.

Any ideas as to what's going on?

5
  • I think it's template_url... Aug 23, 2012 at 1:14
  • Hello there, i edited the question and i also tried "template_url" and nothing.
    – somdow
    Sep 4, 2012 at 19:58
  • Can you please add the entire code that produces the <div class="fl patiothumbs"> and <div class="fr patiothumbs"> output? Your image paths are working properly on all image tags but the two in these DIVs. Sep 4, 2012 at 20:18
  • 1
    @somdow - the URLs seems to be produced correctly, so make sure that the missing images are actually on your server. Going to one directly, for instance, gives me a 403. Sep 4, 2012 at 20:20
  • Yep funny enough as i was trying out some other things, it hit me to check file permissions and sure enough SOMEHOW, the images are set to OWNER READ ONLY hence the not showing up on the browser. So now im gonna call the host to see what the problem is because its nothappening to all the images, just some.....somehow lol
    – somdow
    Sep 4, 2012 at 20:48

1 Answer 1

1

Use get_stylesheet_directory_uri() and get_template_directory_uri() instead. Note that these functions return rather than echo their result. So, for example:

<img src="<?php echo get_template_directory_uri();?>/images/Lynx.gif" alt="castandtubular"/>
3
  • Hello Chip. ive used Both functions and the same thing. On my local machine, it works just fine but when i upload it the link fails to load(based on what FF tells me) The weird thing is that, youd think it would happen site wide but its not. <---loosing my mind
    – somdow
    Sep 4, 2012 at 20:12
  • We'll need to see more code to understand what's going on. Please refer to my comment to your OP. Sep 4, 2012 at 20:18
  • Im going to mark these as the legit answer but its not fixed(nothing to do with wordpress) Somehow, some images permissions are being remade to owner read only so thats why theyre not showing up...kinda just hit me to check and sure enough thats the problem so. Thanks Again for your help. These are wp functions ill def use in the future.
    – somdow
    Sep 4, 2012 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.