0

I am using an image as my site logo, and the image displays fine on the site. However, while the image is inside of an 'a' tag, its not clickable. Here's my code:

<div class="site-branding">
   <a href="<?php echo bloginfo('url'); ?>">
      <img class="site-logo img-responsive" src="<?php echo bloginfo('url'); ?>/wp-content/uploads/2015/07/logo-height-150.png" />
   </a>
   <img class="description-n-landscape img-responsive" src="<?php echo bloginfo('url'); ?>/wp-content/uploads/2015/07/description-n-landscape.png">

</div>

4 Answers 4

2

Can you try with this code? Because bloginfo() does already echo, you need to remove the echo.

<div class="site-branding">
   <a href="<?php bloginfo('url'); ?>">
      <img class="site-logo img-responsive" src="<?php bloginfo('url'); ?>/wp-content/uploads/2015/07/logo-height-150.png" />
   </a>
   <img class="description-n-landscape img-responsive" src="<?php bloginfo('url'); ?>/wp-content/uploads/2015/07/description-n-landscape.png" />

</div>
1
  • I removed the 'echo', and from the source of the page in my browser, I can see that the <a> tag is correctly putting out the URL. However, that did not change the status of the logo not being clickable... still bewildered.
    – Adnan Khan
    Commented Jul 31, 2015 at 21:43
2

You can use the home_url() function for your href and don't forget to sanitize the URL, when putting it into tag attributes like href, with esc_url().

<?php echo esc_url( home_url( '/' ) ); ?>
3
  • Do you know that your site has been hacked? Commented Jul 29, 2015 at 10:41
  • Yup I know, it's an old site I don't use anymore. I just changed my info to my current site. But I am going to take down the hacked site soon anyway. Thanks for the tip. Commented Jul 29, 2015 at 13:02
  • Probably better, unless you want to be associated with fundamentalist Islamic forces. Commented Jul 29, 2015 at 13:05
1

Because bloginfo() does already echo, you need to remove echo from your posted snippet, making the href <?php bloginfo('url'); ?>.

0

Just Change

<a href="<?php echo bloginfo('url'); ?>">

to

<a href="<?php echo home_url(); ?>">

That's all. I am sure this will work.

Your Answer

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

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