how to add a logo on custom wordpress theme

267 Views Asked by At

I'm building a WordPress theme from scratch at the moment and I seem to be stuck on trying to add a logo to the top left corner of the page where you would normally see the title of the page.

<h1>
  <a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a
</h1>
<div class="site-description">
    <h3>
        <?php echo html_entity_decode(get_bloginfo('description')); ?>
    </h3>
</div>`

So instead of the h1 tag there, I would like an image that will allow the user to return to the homepage. Also would I need to save the image in a specific folder ?

Please help and thank you in advance !

2

There are 2 best solutions below

3
On BEST ANSWER

try this

<img src="<?php bloginfo('template_directory'); ?>/images/logo.jpg" />
<div class="site-description">
    <h3>
        <?php echo html_entity_decode(get_bloginfo('description')); ?>
    </h3>
</div>

assuming that image is in the images folder of template directory with file name logo.jpg

1
On

Use <a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?> <img src="image.jpg" width="32" height="32"> </a>

instead of

<h1> <a href="<?php echo home_url(); ?>"><?php bloginfo('name'); ?></a </h1>

Working well for me

See the image https://i.stack.imgur.com/Vs23W.jpg