0

I'm doing some small updates to a WordPress site which is managed as a git repository. The deployment process goes something like, commit to git, push to git repo, ssh to the instance, do a git pull.

Now how can I update the site logo? The theme header is using the_custom_logo() and so from what I can tell this file has to be uploaded. The site and git repo already has a bunch of things in wp-content/uploads which is where the current logo is but just putting a file in here doesn't mean it has an ID or other metadata right?

I'm confused how the person before me did this. Is there a way to just add the logo to the site files and have the site update automatically?

Ideally I'd like to keep using the_custom_logo() because it does a bunch of stuff that I would rather not duplicate and have to keep up to date with upstream.

1
  • Custom logos are (IIRC) stored in the media library although the ID to use is fetched from the theme. You could overwrite the existing files with versions of the new logo that are exactly the same size, but the best way is probably to add and configure the new logo in the site dashboard although note that that will be both a database and filesystem change. How do you handle database updates and versioning in your deployment process? – Rup May 3 at 23:11
1

Now how can I update the site logo? The theme header is using the_custom_logo() and so from what I can tell this file has to be uploaded.

If your theme is using the_custom_logo() then you can edit it by going to Appearance > Header, as described here.

I'm confused how the person before me did this. Is there a way to just add the logo to the site files and have the site update automatically?

You would need to add the logo file to the theme (or child theme) and replace the the_custom_logo() with the HTML for a logo that references that file. You can use get_theme_file_uri() to get the URL for an image in the theme.

Ideally I'd like to keep using the_custom_logo() because it does a bunch of stuff that I would rather not duplicate and have to keep up to date with upstream.

That function is designed for use with images uploaded to the media library, and isn't really usable without an image uploaded to the media library, since that's where it gets all the information from.

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.