Title: WP_Icons_Registry::get_content
Published: May 20, 2026

---

# WP_Icons_Registry::get_content( string $icon_name ): string|null

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_icons_registry/get_content/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_icons_registry/get_content/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_icons_registry/get_content/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_icons_registry/get_content/?output_format=md#related)

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

Retrieves the content of a registered icon.

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

 `$icon_name`stringrequired

Icon name including namespace.

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

 string|null The content of the icon, if found.

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

    ```php
    protected function get_content( $icon_name ) {
    	if ( ! isset( $this->registered_icons[ $icon_name ]['content'] ) ) {
    		$content = file_get_contents(
    			$this->registered_icons[ $icon_name ]['filePath']
    		);
    		$content = $this->sanitize_icon_content( $content );

    		if ( empty( $content ) ) {
    			wp_trigger_error(
    				__METHOD__,
    				__( 'Icon content does not contain valid SVG markup.' )
    			);
    			return null;
    		}

    		$this->registered_icons[ $icon_name ]['content'] = $content;
    	}
    	return $this->registered_icons[ $icon_name ]['content'];
    }
    ```

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

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

| Uses | Description | 
| [WP_Icons_Registry::sanitize_icon_content()](https://developer.wordpress.org/reference/classes/wp_icons_registry/sanitize_icon_content/)`wp-includes/class-wp-icons-registry.php` |

Sanitizes the icon SVG content.

  | 
| [wp_trigger_error()](https://developer.wordpress.org/reference/functions/wp_trigger_error/)`wp-includes/functions.php` |

Generates a user-level error/warning/notice/deprecation message.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  |

[Show 1 more](https://developer.wordpress.org/reference/classes/wp_icons_registry/get_content/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_icons_registry/get_content/?output_format=md#)

| Used by | Description | 
| [WP_Icons_Registry::get_registered_icon()](https://developer.wordpress.org/reference/classes/wp_icons_registry/get_registered_icon/)`wp-includes/class-wp-icons-registry.php` |

Retrieves an array containing the properties of a registered icon.

  | 
| [WP_Icons_Registry::get_registered_icons()](https://developer.wordpress.org/reference/classes/wp_icons_registry/get_registered_icons/)`wp-includes/class-wp-icons-registry.php` |

Retrieves all registered icons.

  |

## User Contributed Notes

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