php blog image problem

by 4 replies
5
Hello Warriors,
I'm not sure what to do with this coding:
<a href="#" rel="bookmark" title="Permanent Link to yoursite.com">
<img src="<?php bloginfo('template_directory'); ?>/images/ad1.gif" /></a>

I can put in the first tag, no problem it's straight html but how do I use the second
half?

I know how to use <img src="whatever"> in html, but am I supposed to split the code
like this:
<img src="humptydumpty"><?php bloginfo('template_directory'); ?>/images/egg.gif" />

Or is this part: <?php bloginfo('template_directory'); ?> in the wrong place?

If it was html, here's how I'd handle it:
<img src="humptydumpty.com"/images/egg.gif" />

Hope this makes sense. I've been playing with it all day and my blog isn't finished until I figure this out (with a little help from my friends

Thank you
#programming #blog #image #php #php learning help #problem
  • [DELETED]
  • Hello solotr,
    Your first example looks correct to me, but remember that you cannot call PHP code from inside a post or page in WordPress. That is reserved for actual PHP files, such as editing your theme or creating your own PHP files on your web server. Take a look at this blog post for a WP plugin to allow execution of PHP inside a post or page.

    Execute PHP in Wordpress post, page and Widget Sidebar | Wordpress

    Let me know if that helps. Thank you.
  • The PHP expression "<?php bloginfo('template_directory'); ?>" is a variable that represents the full path to your blogs theme folder. If you wanted to strip out the PHP and just use HTML you could replace this expression with something like "http://myblogurl.com/public_html/wp-...hemes/mytheme/" .
  • Sorry it took me this long to reply, I moved Also changed hosts, removed that theme and learning php.
  • I build my template the way I like it.
    It has multiple files that in the end combines to the full layout.
    Like multiple CSS and template files.

Next Topics on Trending Feed