HTTP/2 301
server: nginx
date: Sat, 27 Dec 2025 01:15:32 GMT
content-type: text/html; charset=UTF-8
x-olaf: ⛄
vary: accept, content-type
x-redirect-by: WordPress
location: https://developer.wordpress.org/reference/hooks/widget_text/
x-frame-options: SAMEORIGIN
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
HTTP/2 200
server: nginx
date: Sat, 27 Dec 2025 01:15:32 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
x-olaf: ⛄
vary: accept, content-type
link:
; rel="https://api.w.org/"
link:
; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
x-frame-options: SAMEORIGIN
content-encoding: gzip
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
widget_text – Hook | Developer.WordPress.org
apply_filters( ‘widget_text’, string $text, array $instance, WP_Widget_Text|WP_Widget_Custom_HTML $widget )
Filters the content of the Text widget.
May also apply to some third party widgets as well. This filter hook can be used to replace any text within sidebar widgets.
| Version | Description |
|---|
| 4.8.1 | The $widget param may now be a WP_Widget_Custom_HTML object in addition to a WP_Widget_Text object. |
| 4.4.0 | Added the $widget parameter. |
| 2.3.0 | Introduced. |
Example migrated from Codex:
The following performs a string replace on the content of the Text widget.