<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/hands-on-with-the-wordpress-7-1-icon-registration-api-d4ftugaub" -->

---
title: Hands-on with the WordPress 7.1 Icon Registration API
description: WordPress 7.1 ships a public Icon Registration API that lets plugins and themes register custom SVG icon collections for use with the Icon block, addressing a...
canonical: https://daily.dev/posts/hands-on-with-the-wordpress-7-1-icon-registration-api-d4ftugaub
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Hands-on with the WordPress 7.1 Icon Registration API | daily.dev
og:description: WordPress 7.1 ships a public Icon Registration API that lets plugins and themes register custom SVG icon collections for use with the Icon block, addressing a...
og:url: https://daily.dev/posts/hands-on-with-the-wordpress-7-1-icon-registration-api-d4ftugaub
og:image: https://api.daily.dev/og/posts/D4fTugaub.png
og:image:alt: Hands-on with the WordPress 7.1 Icon Registration API
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Hands-on with the WordPress 7.1 Icon Registration API

**[WordPress Developer](https://daily.dev/sources/wordpressdev)** · 13 min read · 1 upvotes · 0 comments

## Summary

WordPress 7.1 ships a public Icon Registration API that lets plugins and themes register custom SVG icon collections for use with the Icon block, addressing a limitation from the 7.0 Icon block launch. The tutorial covers wp_register_icon_collection() and wp_register_icon() functions, then walks through building a complete restaurant icon plugin using a PHP string-backed enum for type-safe icon references. Current limitations include a restricted SVG element allowlist (only svg, path, polygon), stripped stroke attributes, and no built-in editor component for icons in other blocks yet, with work ongoing for 7.2.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://developer.wordpress.org/news/2026/08/hands-on-with-the-wordpress-7-1-icon-registration-api>

## Questions this post answers

### How do I register a custom icon collection and icons in WordPress 7.1?

Use the new public functions wp_register_icon_collection(string $slug, array $args) to register a collection with a label and description, then wp_register_icon(string $icon_name, array $icon_properties) for each icon, providing a label plus either inline SVG content or a file_path. Both calls should run on the init hook, and icon names must be namespaced as collection-slug/icon-slug.

_Developers wiring up custom icon collections can track WordPress API changes like this via daily.dev._

### What SVG elements and attributes are allowed for custom icons in WordPress 7.1?

Only svg, path, and polygon elements are permitted; everything else is stripped because WordPress lacks a formal SVG sanitization function yet. The stroke attribute is stripped entirely, so icons must rely on fill for coloring, and fill itself is removed from the outer svg tag but preserved on path and polygon elements. Broader element support and stroke handling are being worked on for a future release.

_Anyone building icon plugins can watch for SVG sanitization updates in WordPress via daily.dev._

### Why use a PHP string-backed enum instead of an array to manage icon names in a WordPress plugin?

A string-backed enum, available since PHP 8.1, gives compile-time type safety and IDE autocompletion that a plain array key cannot: Icon::Cake is a real, checkable type, whereas an array key like $icons['cake'] is just a string that can typo and silently break at runtime. Methods like label(), handle(), and filePath() live directly on the enum, and PHP's match() warns via static analysis or an UnhandledMatchError if a case is left unhandled.

_PHP developers weighing enums versus arrays for config data can find practical comparisons on daily.dev._

## Similar posts on daily.dev

- [Registering and rendering SVG icons in WordPress 7.1](https://daily.dev/posts/registering-and-rendering-svg-icons-in-wordpress-7-1-5vc0sqsrb) · Make WordPress Core · 9 upvotes · 3 comments
- [WordPress PHP-Only Block Registration](https://daily.dev/posts/wordpress-php-only-block-registration-ocqm8qoge) · CSS-Tricks · 3 upvotes · 0 comments
- [Replacing Dashicons in the admin bar and menu](https://daily.dev/posts/replacing-dashicons-in-the-admin-bar-and-menu-pcbeyavxw) · Make WordPress Core · 11 upvotes · 0 comments
- [Introducing the WordPress Abilities API](https://daily.dev/posts/introducing-the-wordpress-abilities-api-7cle9rxc4) · WordPress Developer · 18 upvotes · 0 comments

---

Tags: [#php](https://daily.dev/tags/php), [#wordpress](https://daily.dev/tags/wordpress), [#svg](https://daily.dev/tags/svg)

[View this post on daily.dev](https://daily.dev/posts/hands-on-with-the-wordpress-7-1-icon-registration-api-d4ftugaub)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Hands-on with the WordPress 7.1 Icon Registration API","url":"https://daily.dev/posts/hands-on-with-the-wordpress-7-1-icon-registration-api-d4ftugaub","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/hands-on-with-the-wordpress-7-1-icon-registration-api-d4ftugaub"},"datePublished":"2026-08-18T20:44:51.746Z","dateModified":"2026-09-14T06:05:51.548Z","description":"WordPress 7.1 ships a public Icon Registration API that lets plugins and themes register custom SVG icon collections for use with the Icon block, addressing a...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d86da7895385928695e1b0f6ddf160e8?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d86da7895385928695e1b0f6ddf160e8?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"WordPress Developer","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"WordPress Developer","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/cf1b3c66d466440aac9b5e5092d93e86","url":"https://daily.dev/sources/wordpressdev"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/hands-on-with-the-wordpress-7-1-icon-registration-api-d4ftugaub","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"php,wordpress,svg","timeRequired":"PT13M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"WordPress Developer","item":"https://daily.dev/sources/wordpressdev"},{"@type":"ListItem","position":3,"name":"Hands-on with the WordPress 7.1 Icon Registration API"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/hands-on-with-the-wordpress-7-1-icon-registration-api-d4ftugaub#faq","mainEntity":[{"@type":"Question","name":"How do I register a custom icon collection and icons in WordPress 7.1?","acceptedAnswer":{"@type":"Answer","text":"Use the new public functions wp_register_icon_collection(string $slug, array $args) to register a collection with a label and description, then wp_register_icon(string $icon_name, array $icon_properties) for each icon, providing a label plus either inline SVG content or a file_path. Both calls should run on the init hook, and icon names must be namespaced as collection-slug/icon-slug. Developers wiring up custom icon collections can track WordPress API changes like this via daily.dev."}},{"@type":"Question","name":"What SVG elements and attributes are allowed for custom icons in WordPress 7.1?","acceptedAnswer":{"@type":"Answer","text":"Only svg, path, and polygon elements are permitted; everything else is stripped because WordPress lacks a formal SVG sanitization function yet. The stroke attribute is stripped entirely, so icons must rely on fill for coloring, and fill itself is removed from the outer svg tag but preserved on path and polygon elements. Broader element support and stroke handling are being worked on for a future release. Anyone building icon plugins can watch for SVG sanitization updates in WordPress via daily.dev."}},{"@type":"Question","name":"Why use a PHP string-backed enum instead of an array to manage icon names in a WordPress plugin?","acceptedAnswer":{"@type":"Answer","text":"A string-backed enum, available since PHP 8.1, gives compile-time type safety and IDE autocompletion that a plain array key cannot: Icon::Cake is a real, checkable type, whereas an array key like $icons['cake'] is just a string that can typo and silently break at runtime. Methods like label(), handle(), and filePath() live directly on the enum, and PHP's match() warns via static analysis or an UnhandledMatchError if a case is left unhandled. PHP developers weighing enums versus arrays for config data can find practical comparisons on daily.dev."}}]}
```

