1

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' ) ); ?> &mdash; <?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:

  1. 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.
  2. 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?

1

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

<div class="header section" style="background-image: url(<?php if (get_header_image() != '') : ?><?php header_image(); ?><?php else : ?><?php echo get_template_directory_uri() . '/images/header.jpg'; ?><?php endif; ?>);">

is where the image is called, so you just need to modify that. Remember to change

get_template_directory_uri() . '/images/header.jpg

to

get_stylesheet_directory_uri() . '/images/your-image.jpg

I hope this help.

  • 1
    Thanks. I was able to create a child theme and hack it. However, I find my solution to be suboptimal because I shouldn't have to hack a theme just to use features that it supports. Why couldn't it just make the logo path clear so I can drop my logo there? – Scott Severance Apr 10 '14 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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