WP-CLI
Manage fonts from the command line with 10 wp nahnu-fonts commands. They’re handy for scripts, deployments and setting up many sites the same way.
Commands#
| Command | Does |
|---|---|
wp nahnu-fonts list [--format=<format>] | Lists fonts with id, name, source, active, styles and CSS variable. Formats: table (default), json, csv, yaml |
wp nahnu-fonts add-google <family> [--weights=<list>] [--italic] [--subsets=<list>] [--variable] | Downloads a Google Fonts family through the source set in Settings. Defaults: weights 400,700, subsets latin. --variable needs the Google source |
wp nahnu-fonts enable <id>... | Switches fonts on |
wp nahnu-fonts disable <id>... | Switches fonts off (kept, but not loaded) |
wp nahnu-fonts delete <id>... | Deletes fonts and their files |
wp nahnu-fonts rebuild | Rebuilds the stylesheet |
wp nahnu-fonts export <file> [--fonts=<ids>] | Exports fonts and settings to a .zip. Default: all fonts |
wp nahnu-fonts import <file> | Imports a .zip exported from Nahnu Fonts |
wp nahnu-fonts setting <key> [<value>] | Shows a setting, or changes it when you give a value |
wp nahnu-fonts adobe <project-id> or --disconnect | Connects (or refreshes) an Adobe Fonts project, or disconnects it |
Font ids are shown by wp nahnu-fonts list. They’re based on the family name, for example inter or open-sans.
Settings keys#
For wp nahnu-fonts setting, use true or false for switches and a comma-separated list for default_subsets.
| Key | Values | Default |
|---|---|---|
source | bunny, google | bunny |
font_display | swap, fallback, optional, block, auto | swap |
default_subsets | e.g. latin,latin-ext | latin |
block_editor | true, false | true |
css_variables | true, false | true |
purge_cache | true, false | true |
inline_css | true, false | false |
block_google_fonts | true, false | false |
builder_google_fonts_off | true, false | true |
jooosi_compat | true, false | false (on after a move) |
delete_on_uninstall | true, false | false |
adobe_project_id | use wp nahnu-fonts adobe instead | empty |
integrations_off | integration names, e.g. elementor,bricks | empty |
Examples#
Set up a new site with two families:
wp plugin activate nahnu-fonts
wp nahnu-fonts add-google "Inter" --weights=400,600,700 --subsets=latin,latin-ext
wp nahnu-fonts add-google "Lora" --weights=400,700 --italic
wp nahnu-fonts setting font_display swap Copy fonts from staging to live:
# On staging
wp nahnu-fonts export /tmp/fonts.zip
# On live
wp nahnu-fonts import /tmp/fonts.zip Get the variable version of a font:
wp nahnu-fonts setting source google
wp nahnu-fonts add-google "Inter" --variable Check which fonts are active, as JSON:
wp nahnu-fonts list --format=json