Solved: WordPress custom fonts not loading on iOS

I recently changed my WP theme to Twenty Twenty-Four and added custom fonts, but weirdly it won’t be displayed on iOS while it works well on Android.

Tried numerous possible solutions and failed. But now I have a fix. It appears the theme keeps overriding style.css whatever you do on the stylesheet like !important.

Making it loaded after theme’s CSS fixes the issue. Added the following code to your theme’s functions.php:

function enqueue_custom_fonts() {
    wp_enqueue_style('custom-fonts', get_stylesheet_uri(), [], false, 'all');
}
add_action('wp_enqueue_scripts', 'enqueue_custom_fonts', 20);

Comments

Leave a Reply