1

I have a problem with my wordpress site logo. I cannot make the site logo dynamic.

here is my code (displaying logo) which is in header.php page:

<a  href="<?php echo get_home_url(); ?>" id="logo">
    <img src="<?php echo get_template_directory_uri(); ?>/assets/images/logo.png" class="img-responsive" alt="" title="">
</a>

***** when I want to change it from Customize > Site Identity, here it shows that no logo is attached, yet the logo is displaying successfully at front-end. Even when I try to change it, nothing happens.

Kindly help me to solve this issue.

3 Answers 3

1

Theme header logo function get_theme_mod( 'custom_logo' );

$custom_logo_id = get_theme_mod( 'custom_logo' );
$image = wp_get_attachment_image_src( $custom_logo_id , 'full' );
echo '<img class="header_logo" src="'.$image[0].'">';
2
  • Thank you for sharing ur great answer. There is some design issue, i.e. the logo is displaying too large. May I need to change the img css only or there is/are something new function/parameter available to do this ?? Jan 3, 2018 at 7:33
  • either scale the image to exact dimensions and re-upload, or at least make sure the proportions are exactly what you want then do then rest with CSS
    – majick
    Jan 3, 2018 at 10:40
0
$image = wp_get_attachment_image_src( $custom_logo_id , 'full' );

Just change the 'full' to 'thumbnail' or something else. You can also define custom sizes. Or you could target it by the class 'header_logo' in css.

1
  • Many many many many thanx to you. Your suggestion "thumbnail" saves my valuable time. May be this was the code I was looking for. thank you once again. Jan 3, 2018 at 10:21
0

Use this code in header.php :

<img src="<?php header_image(); ?>" alt="">

Then open site wp-admin : Go to apperence -> customize -> Header Image and upload logo and publish it

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.