We have a setup where bloggers can and will have their theme changed. Is it possible to migrate the existing header image to the new theme ? I know how to override the header image with the add_filter, also know how to get the current header image. The issue here is to keep the header image when changing the theme. Is that possible ?
Leave a Reply
You must be logged in to post a comment.
Here comes the plugins to rescue, move that code into a plugin and activate. That’ll not change header image upon every theme change.
E.g –
save it as
whatever-foo.php
upload to/wp-content/plugins/
directory and activate itThe header image is set per â¦
⦠a wrapper for â¦
So you can hook into â¦
⦠take the first parameter, which is an array of all theme mods, and save the value of the key
'header_image'
in a plugin option. The key'header_image_data'
stores the meta data for that image.Then filter
'theme_mod_header_image'
to return your stored plugin option if there is no image set.We did a small mu-plugin that solved our issue.
Here is the code