Adding Google Fonts in WordPress Themes — a practical guide to WordPress Google Fonts with clear examples you can reuse in real projects.
WordPress Theme Development Series (42/96). Prefer one article? Read the complete WordPress theme development tutorial.
Short description
Prefer self-hosted fonts for GDPR/performance. If using Google CSS, enqueue it and preconnect carefully.
Enqueue font stylesheet
wp_enqueue_style(
'acme-fonts',
'https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;700&display=swap',
[],
null
);