Title: WP_REST_Icons_Controller::get_icon
Published: May 20, 2026

---

# WP_REST_Icons_Controller::get_icon( string $name ): array|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

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

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

Retrieves a specific icon from the registry.

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

 `$name`stringrequired

Icon name.

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

 array|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) Icon
data on success, or [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
object on failure.

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

    ```php
    public function get_icon( $name ) {
    	$registry = WP_Icons_Registry::get_instance();
    	$icon     = $registry->get_registered_icon( $name );

    	if ( null === $icon ) {
    		return new WP_Error(
    			'rest_icon_not_found',
    			sprintf(
    				// translators: %s is the name of any user-provided name
    				__( 'Icon not found: "%s".' ),
    				$name
    			),
    			array( 'status' => 404 )
    		);
    	}

    	return $icon;
    }
    ```

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

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

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

Utility method to retrieve the main instance of the class.

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

Retrieves the translation of $text.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

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

| Used by | Description | 
| [WP_REST_Icons_Controller::get_item()](https://developer.wordpress.org/reference/classes/wp_rest_icons_controller/get_item/)`wp-includes/rest-api/endpoints/class-wp-rest-icons-controller.php` |

Retrieves a specific icon.

  |

## User Contributed Notes

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