Title: WP_Interactivity_API_Directives_Processor::get_balanced_tag_bookmarks
Published: April 3, 2024
Last modified: August 20, 2026

---

# WP_Interactivity_API_Directives_Processor::get_balanced_tag_bookmarks(): array|null

## In this article

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Returns a pair of bookmarks for the current opener tag and the matching closer tag.

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

It positions the cursor in the closer tag of the balanced tag, if it exists.

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

 array|null A pair of bookmarks, or null if there’s no matching closing tag.

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

    ```php
    private function get_balanced_tag_bookmarks() {
    	static $i   = 0;
    	$opener_tag = 'opener_tag_of_balanced_tag_' . ++$i;

    	$this->set_bookmark( $opener_tag );
    	if ( ! $this->next_balanced_tag_closer_tag() ) {
    		$this->release_bookmark( $opener_tag );
    		return null;
    	}

    	$closer_tag = 'closer_tag_of_balanced_tag_' . ++$i;
    	$this->set_bookmark( $closer_tag );

    	return array( $opener_tag, $closer_tag );
    }
    ```

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

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

| Uses | Description | 
| [WP_Interactivity_API_Directives_Processor::next_balanced_tag_closer_tag()](https://developer.wordpress.org/reference/classes/wp_interactivity_api_directives_processor/next_balanced_tag_closer_tag/)`wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php` |

Finds the matching closing tag for an opening tag.

  |

| Used by | Description | 
| [WP_Interactivity_API_Directives_Processor::get_after_opener_tag_and_before_closer_tag_positions()](https://developer.wordpress.org/reference/classes/wp_interactivity_api_directives_processor/get_after_opener_tag_and_before_closer_tag_positions/)`wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php` |

Gets the positions right after the opener tag and right before the closer tag in a balanced tag.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_interactivity_api_directives_processor/get_balanced_tag_bookmarks/?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%2Fclasses%2Fwp_interactivity_api_directives_processor%2Fget_balanced_tag_bookmarks%2F)
before being able to contribute a note or feedback.