Local Font URLs Not Updating After Push to WP Engine

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