INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

template_directory not showing img, just echoing some text

template_directory not showing img, just echoing some text

template_directory not showing img, just echoing some text

(OP)
I'm using a theme (my own) and I'm trying to use the relative path feature, template_directory. Unfortunately all it does is echo the code that follows it. Do I need to tell wordpress what the template_directory is somewhere? Currently I'm using this code:

CODE

<img name=scribble_r2_c1 src=<?php bloginfo('template_directory'); ?>images/scribble_r2_c1-line.gif width=83 height=29 border=0>

I've tried putting a slash in front of the images folder and wrapping the img src in ', but to no avail. I've even tried stylesheet_url as that seems to work in calling the stylesheet. The actual path for the image is:


http://www.followtheboat.com/wp-content/themes/followtheboat/images/scribble_r2_c1-line.gif

Could anyone point me in the right direction?

RE: template_directory not showing img, just echoing some text

the bloginfo() call shoudl work fine. but your html attributes are not properly enquoted

CODE

<img name="scribble_r2_c1" src="<?php bloginfo('template_directory'); ?>/images/scribble_r2_c1-line.gif" width="83" height="29" border="0" />

RE: template_directory not showing img, just echoing some text

(OP)
Hi,

That's because they sit in a <?php wrap which uses double quotes. I assumed that not using any quotes was ok. You can get away with not using quotes in html. I'm back to my annoying internet connection problems again so I'll try your suggestion tomorrow.

Thank you.

RE: template_directory not showing img, just echoing some text

it's not really ok not to use quotes for html attributes. you've just been lucky.

but in fact your response provides the answer. which is more or less the same as the answer i gave you the other day. bloginfo() is an output function.  if you use it in a string like you say you are, the output will be placed BEFORE the string itself.  take a look at the source of your html output and you'll see what I mean.

so either you need to do the following

CODE


// break out of php
?>
<img name="scribble_r2_c1" src="<?php bloginfo('template_directory'); ?>/images/scribble_r2_c1-line.gif" width="83" height="29" border="0" />
<?php //break back into php

or you should use a return function rather than an output function

CODE

echo <<<HTML
<img name="scribble_r2_c1" src="
HTML
. get_bloginfo('template_directory') . <<<HTML
/images/scribble_r2_c1-line.gif" width="83" height="29" border="0" />
HTML;

or more traditionally

CODE

echo '<img name="scribble_r2_c1" src="' . get_bloginfo('template_directory') . '/images/scribble_r2_c1-line.gif" width="83" height="29" border="0" />';

or even

CODE

echo "<img name=\"scribble_r2_c1\" src=\"".bloginfo('template_directory')."/images/scribble_r2_c1-line.gif\" width=\"83\" height=\"29\" border=\"0\" />";

RE: template_directory not showing img, just echoing some text

(OP)
Blimey, you know your onions! Thank you once again for your time, I really appreciate it. I am trying to work my way through the logic...it's taking some time but I'm getting there, with your help. Thank you once again.

RE: template_directory not showing img, just echoing some text

apologies to readers, the last code block of my post above should refer to get_bloginfo('template_directory') and not just bloginfo('template_directory'), for the reasons given in the body of the post itself.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close