Skip to content
Docs
Get RestroPress

Filter

widget_title

Updated
On this page

Filters the widget title for RestroPress widgets.

This is the standard WordPress widget_title filter. RestroPress applies it in the cart widget, the categories and tags widget, and the menu item details widget before printing the title. Because the same hook runs for every widget, check the sidebar ID or instance when you only want to affect one.

Parameters#

ParameterTypeDescription
$titlestringThe widget title from the saved instance, or an empty string.
$instancearrayThe widget instance settings.
$sidebar_idstringThe sidebar ID, or the widget default ID when not set.

Return value#

string. The widget title.

Example#

function my_widget_title( $title, $instance, $sidebar_id ) {
	if ( 'sidebar-shop' === $sidebar_id && $title ) {
		$title .= ' (order online)';
	}
	return $title;
}
add_filter( 'widget_title', 'my_widget_title', 10, 3 );

Notes#

WordPress core hook. RestroPress prints the title through esc_html(), so HTML is escaped. The cart widget and categories widget use rpress_cart_widget and rpress_categories_tags_widget as the default ID.

Source#

Applied in:

  • includes/widgets.php (line 45), in rpress_cart_widget::widget()
  • includes/widgets.php (line 128), in rpress_categories_tags_widget::widget()
  • includes/widgets.php (line 235), in RPRESS_Product_Details_Widget::widget()
Was this page helpful?