widget_text WordPress Filter Hook

The widget_text hook is one of the most versatile hooks in WordPress. It allows you to add content to your sidebar widgets without having to write any code. You can use HTML, shortcodes, and even embed videos and images.

apply_filters( 'widget_text', string $text, array $instance, WP_Widget_Text|WP_Widget_Custom_HTML $widget ) #

Filters the content of the Text widget.


Parameters

$text

(string)The widget content.

$instance

(array)Array of settings for the current widget.

$widget

(WP_Widget_Text|WP_Widget_Custom_HTML)Current text or HTML widget instance.


Top ↑

More Information

May also apply to some third party widgets as well. This filter hook can be used to replace any text within sidebar widgets.


Top ↑

Source

File: wp-includes/widgets/class-wp-widget-text.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.8.1The $widget param may now be a WP_Widget_Custom_HTML object in addition to a WP_Widget_Text object.
4.4.0Added the $widget parameter.
2.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.