Theme Update Script for Custom Logo

I’ve been updating several of my themes to support the new custom logo feature that is being introduced in WordPress 4.5 (read about it here).

Most of my themes already had a logo option, so part of adding support for this new feature has been to build an update script to migrate the previously saved value (generally saved to the theme mod “logo”), to the new theme mod “custom_logo”.

I assume a lot of other theme authors will also be doing this, so I’m sharing my update code in case it can save someone a few minutes.

A few things to note:

  • You’ll likely need to tweak it to match your current theme_mod/setting for the logo.
  • I saved my logo value as a URL, so this script converts it to an attachment ID before saving it into the new theme_mod

[gist id=”7af792846055f8130f3b”]

If you see any improvements that can be made, feel free to edit the Gist!

About Devin

I am a developer based in Austin, Texas. I run a little theme shop called DevPress and help manage a WooCommerce shop with Universal Yums. Find me on twitter @devinsays.

3 Responses

  1. This piece of code is OK for Custom Logo feature for the existing theme. But if someone is an using option panel like Redux, they can’t use this code so how they can manage it easily?

Leave a Reply