Title: WP_HTML_Processor::get_breadcrumbs
Published: November 8, 2023
Last modified: February 24, 2026

---

# WP_HTML_Processor::get_breadcrumbs(): string[]

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_html_processor/get_breadcrumbs/?output_format=md#description)
 * [Return](https://developer.wordpress.org/reference/classes/wp_html_processor/get_breadcrumbs/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_html_processor/get_breadcrumbs/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_html_processor/get_breadcrumbs/?output_format=md#changelog)

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

Computes the HTML breadcrumbs for the currently-matched node, if matched.

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

Breadcrumbs start at the outermost parent and descend toward the matched element.

They always include the entire path from the root HTML node to the matched element.

Example:

    ```php
    $processor = WP_HTML_Processor::create_fragment( '<p><strong><em><img></em></strong></p>' );
    $processor->next_tag( 'IMG' );
    $processor->get_breadcrumbs() === array( 'HTML', 'BODY', 'P', 'STRONG', 'EM', 'IMG' );
    ```

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

 string[] Array of tag names representing path to matched node.

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

    ```php
    public function get_breadcrumbs(): array {
    	return $this->breadcrumbs;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/html-api/class-wp-html-processor.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/html-api/class-wp-html-processor.php#L1173)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/html-api/class-wp-html-processor.php#L1173-L1175)

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

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

## User Contributed Notes

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