# Remove Positive Tabindex Values From Content

> Removes tabindex values greater than zero from links and fields in post content, which otherwise force a confusing keyboard order, while keeping tabindex 0 and -1.

- Type: PHP
- Runs: Frontend only
- Category: [Accessibility](https://wpide.com/library/category/accessibility/)
- Tags: keyboard, tabindex, content
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/a11y-remove-positive-tabindex/

## Code

```php
add_filter( 'the_content', function ( $content ) {
    if ( false === stripos( $content, 'tabindex' ) || ! class_exists( 'WP_HTML_Tag_Processor' ) ) {
        return $content;
    }

    $tags = new WP_HTML_Tag_Processor( $content );

    while ( $tags->next_tag() ) {
        $value = $tags->get_attribute( 'tabindex' );

        if ( null !== $value && (int) $value > 0 ) {
            $tags->set_attribute( 'tabindex', '0' );
        }
    }

    return $tags->get_updated_html();
}, 20 );
```

## Notes

Theme and plugin markup outside the post content is not changed.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remove Positive Tabindex Values From Content" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
