Local Font URLs Not Updating After Push to WP Engine

What issue or error are you experiencing?

Using the new local fonts in WordPress 6.5, after pushing from Local to WP Engine those local font urls are not being updated to the wpengingpowered domain.


What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc

  1. Add some custom fonts in the new WordPress Font Library.
  2. Use those fonts somewhere in the site.
  3. Push that site to WP Engine.
  4. Check the links by searching for “wp-fonts-local” in the console.
<style id="wp-fonts-local">
@font-face{font-family:Inter;font-style:normal;font-weight:100 700;font-display:block;src:url('https://testsite.wpenginepowered.com/wp-content/themes/ollie/assets/fonts/Inter-VariableFont_slnt,wght.woff2') format('woff2');font-stretch:normal;}
@font-face{font-family:"Bebas Neue";font-style:normal;font-weight:400;font-display:fallback;src:url('https://testsite.local/wp-content/uploads/fonts/JTUSjIg69CK48gW7PXooxWtrygbi49c.woff2') format('woff2');}
@font-face{font-family:Satisfy;font-style:normal;font-weight:400;font-display:fallback;src:url('https://testsite.local/wp-content/uploads/fonts/rP2Hp2yn6lkG50LoOZGCHBeHFl0.woff2') format('woff2');}
@font-face{font-family:Tajawal;font-style:normal;font-weight:300;font-display:fallback;src:url('https://testsite.local/wp-content/uploads/fonts/Iurf6YBj_oCad4k1l5qjLrNjiLlJ-G0.woff2') format('woff2');}
@font-face{font-family:Tajawal;font-style:normal;font-weight:400;font-display:fallback;src:url('https://testsite.local/wp-content/uploads/fonts/Iura6YBj_oCad4k1rzOLCr5IlLA.woff2') format('woff2');}
@font-face{font-family:Tajawal;font-style:normal;font-weight:700;font-display:fallback;src:url('https://testsite.local/wp-content/uploads/fonts/Iurf6YBj_oCad4k1l4qkLrNjiLlJ-G0.woff2') format('woff2');}
</style>

The fonts uploaded to /wp-content/uploads/fonts/ aren’t getting updated after upload. They are still stuck on the .local domain and didn’t notice this until someone without the fonts installed locally called it out.

I’ve tried clearing WP Engine cache, testing in another browser, using a cach-busting url.

The only fix is a search-replace to change the url in the database (I do it via ssh/wpcli).


System Details

  • Local Version:
    9.0.1

  • Operating System (OS) and OS version:
    Mac OS Sonoma 14.4.1


Local Logs

Attach your Local Logs here (Help Doc - Retrieving Local’s Log)
local-lightning.log (603.7 KB)


Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Hi @bryce

Have you been pushing with the database included? If you don’t include the database this is expected behavior. If you include the database, this should work, but if you’d prefer not to push the database, the only workaround for now will be to patch these manually as you have been.

Hi Nick,

Yes I pushed with the database. It just appears to have missed changing the font urls for some reason.

Did know if it was because the fonts were a new thing in WP and something needed updating to target those.

We’ve seen some issues crop up with the latest WP release so it could be related. If you roll back to the previous WordPress version does it work normally?

What type of theme are you using?

Previous WordPress version doesn’t have the font library in it so falling back would remove all that code completely.

This is just a dev site at the moment so not worried there.

Its using the Ollie theme (https://olliewp.com/) and WordPress 6.5.

Just wanted to reach out in case this was a bug with Local and missing updating those font urls after pushing.

Hey @bryce! I just wanted to let you know I passed this on to our Local devs for review. They’ve been digging in but we don’t have an ETA to provide on a fix. We’ll keep you posted on any developments :green_heart:

2 Likes

Hey Nick and Bryce, I’m not using Local, but was googling around for a solution and stumbled across this post. Managed to solve it and thought I’d pass on what worked for me.

Issue
Wordpress is storing the fonts in the wp_posts table as a JSON object. A search and replace for the plain local urls won’t work. Here’s an example on my local site:

wp_posts → post_content
{"src":"http:\/\/localhost:8888\/wp-content\/uploads\/fonts\/JTUHjIg1_i6t8kCHKm4532VJOt5-QNFgpCtr6Ew7Y3tcoqK5.woff2","fontWeight":"400","fontStyle":"normal","fontFamily":"Montserrat","preview":"https:\/\/s.w.org\/images\/fonts\/17.7\/previews\/montserrat\/montserrat-400-normal.svg"}

I solved it using the wp-cli with a simple search and replace for the escaped url.

  • wp search-replace ':\/\/localhost:8888' ':\/\/domain.com'

Hope that helps! I’m sure your devs are already on top of this.

All the best,

Aslam

4 Likes

Thanks, @aslamh, that helps. I’ve filed a bug for this but don’t have a timeline for a fix just yet. Local would need to change how it handles find/replace on push and test to account for edge-cases. (It currently searches for //example.local, which misses the escaped JSON string in this case.)

Workarounds for now are to run wp search-replace either on the escaped version as you describe, or on a version of the URL without any prefixed // or \/\/.

3 Likes

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.