I’m trying to set up a new site, using the Hemingway theme. I want to add a logo to the header. The theme editor wants me to use the admin panel to upload the logo. There are two problems with this. First, that method is bound to fail, because of course WordPress doesn’t have write access to the filesystem and I’m not about to grant it such access. Second, the normal way to post such things on a website is to upload the relevant files to the server in the proper location and link to them. But where does the logo go?
In my theme, the logo is placed by the following code:
<?php if ( get_theme_mod( 'hemingway_logo' ) ) : ?>
<div class='blog-logo'>
<a href='<?php echo esc_url( home_url( '/' ) ); ?>' title='<?php echo esc_attr( get_bloginfo( 'title' ) ); ?> — <?php echo esc_attr( get_bloginfo( 'description' ) ); ?>' rel='home'>
<img src='<?php echo esc_url( get_theme_mod( 'hemingway_logo' ) ); ?>' alt='<?php echo esc_attr( get_bloginfo( 'title' ) ); ?>'>
</a>
</div> <!-- /blog-logo -->
The way I see it, I have two options:
- Modify the code and hard code my logo here. The problem here is that the more I modify the code, the more maintainability issues I can expect to encounter.
- Figure out where this code expects a logo. It appears that the function
get_theme_mod
is the key, but when I looked up its definition, it appears that there’s quite a tangle of code to follow (and I’ve never heard of an interactive debugger for PHP).
Of these options, I think that number 2 is quite preferable, but I don’t understand the code sufficiently to do it.
What recommendest thou?
I would strongly suggest then that you create a child theme. It is really quick (takes less that 5 minutes) and your customizations doesn’t get lost when you update your theme. You just need to copy ‘header.php’ to your child theme to modify. Also create a folder called ‘images’, this is where your custom logo will go. Line 24
is where the image is called, so you just need to modify that. Remember to change
to
I hope this help.