Title: wp_register_font_collection
Published: April 3, 2024
Last modified: May 20, 2026

---

# wp_register_font_collection( string $slug, array $args ): 󠀁[WP_Font_Collection](https://developer.wordpress.org/reference/classes/wp_font_collection/)󠁿|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#wp--skip-link--target)

Registers a new font collection in the font library.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#description)󠁿

See [https://schemas.wp.org/trunk/font-collection.json](https://schemas.wp.org/trunk/font-collection.json/)
for the schema the font collection data must adhere to.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#parameters)󠁿

 `$slug`stringrequired

Font collection slug. May only contain alphanumeric characters, dashes, and underscores.
See [sanitize_title()](https://developer.wordpress.org/reference/functions/sanitize_title/).

`$args`arrayrequired

Font collection data.

 * `name` string
 * Required. Name of the font collection shown in the Font Library.
 * `description` string
 * Optional. A short descriptive summary of the font collection. Default empty.
 * `font_families` array|string
 * Required. Array of font family definitions that are in the collection, or a string
   containing the path or URL to a JSON file containing the font collection.
 * `categories` array
 * Optional. Array of categories, each with a name and slug, that are used by the
   fonts in the collection. Default empty.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#return)󠁿

 [WP_Font_Collection](https://developer.wordpress.org/reference/classes/wp_font_collection/)
|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) A font 
collection if it was registered successfully, or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
object on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#source)󠁿

    ```php
    function wp_register_font_collection( string $slug, array $args ) {
    	return WP_Font_Library::get_instance()->register_font_collection( $slug, $args );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/fonts.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/fonts.php#L96)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/fonts.php#L96-L98)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Font_Library::get_instance()](https://developer.wordpress.org/reference/classes/wp_font_library/get_instance/)`wp-includes/fonts/class-wp-font-library.php` |

Utility method to retrieve the main instance of the class.

  |

| Used by | Description | 
| [_wp_register_default_font_collections()](https://developer.wordpress.org/reference/functions/_wp_register_default_font_collections/)`wp-includes/fonts.php` |

Register the default font collections.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_register_font_collection/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.5.0](https://developer.wordpress.org/reference/since/6.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_register_font_collection%2F)
before being able to contribute a note or feedback.