John Wooten
John Wooten

Reputation: 21

WordPress Template Directory

How can I get this to work? Thanks in advance!!! I think the first echo should work but it doesn't...it prints out the URL in text instead of showing the image...

<?php
      if (is_tree(18)) {
         echo '<img src="' . bloginfo('template_directory') . '/img/icon-trans.png" />';
      } else if (is_tree(20)) {
          echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconIndustrial-trans.png' />";
      } else if (is_tree(22)) {
          echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconInstitutional-trans.png' />";
      } else if (is_tree(24)) {
          echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconComm-trans.png' />";
      } else if (is_tree(27)) {
          echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconService-trans.png' />";
      } else if (is_tree(39)) {
          echo "<img src='/~cecmsite/wp-content/themes/commonwealth/img/iconTraffic-trans.png' />";
      } else {
      echo "";
      }
      ?>

Upvotes: 0

Views: 602

Answers (2)

Joseph Silber
Joseph Silber

Reputation: 219920

You shouldn't open another PHP block, as that will break your code.

Use concatenation instead:

echo '<img src="' . get_bloginfo('template_directory') . '/img/icon-trans.png" />';

Upvotes: 0

Vasanthan.R.P
Vasanthan.R.P

Reputation: 1287

Instead of using bloginfo('template_directory') use get_bloginfo('template_directory')

Upvotes: 1

Related Questions