Ready to get started?Download WordPress


[resolved] Edit the Widget Title script (3 posts)

  1. napalm
    Posted 4 years ago #

    Hi All,

    I am wanting to add a script to my 'text widget' title that will apply a CSS class to the very first word.

    So no matter what the title is, the first word would always have a CSS applied to it for me to style accordingly.

    My issue is that I cannot find where WP actually places the $title (assuming that variable holds the value of the title) into the <h2> or <h3> widget title.

    If anyone could point me in the direction of this function , or where the scripts actually construct a widget and inserts the $title, it would be greatly appreciated.

    I have looked at the widgets.php file, but dont seem to understand if its actually constructing the text widget here.


  2. kz
    Posted 4 years ago #


    function my_widget_title($title){
      return '<h3>' . $title . '</h3>';
    add_filter('widget_title', 'my_widget_title');
  3. napalm
    Posted 4 years ago #


Topic Closed

This topic has been closed to new replies.

About this Topic