• I want the titles of my widgets to style like this, https://files.gadietrich.com/widget_yes.png. In this example I am using a Text widget without a title, but putting this code in the main box:

    <h3><span class="home_widget"><span class="home_widget_lc">join us</span> on sundays</span></h3>

    This won’t work though if I am using other widgets. So how can I get this type of display with any of my widgets using the title. I am guessing I might have to add another title field, however, I’m clueless on that.

    The site I am working on is https://clients.gadietrich.com/prov

Viewing 2 replies - 1 through 2 (of 2 total)
  • try this:

    add_filter('widget_title', 'custom_widget_title', 10, 1);
    function custom_widget_title($title){
    	$title_array = explode(" ", $title);
    	$count = count($title_array);
    	if($count==1){
    		$title = '<span class="home_widget">' . $title . '</span>';
    	} elseif($count==2){
    		$title = '<span class="home_widget"><span class="home_widget_lc">' . $title_array[0] . '</span> ' . $title_array[1] . '</span>';
    	} elseif($count==3){
    		$title = '<span class="home_widget"><span class="home_widget_lc">' . $title_array[0] . ' ' . $title_array[1] . '</span> ' . $title_array[2] . '</span>';
    	} elseif($count>=4){
    		foreach($title_array as $word_number => $word){
    			if($word_number <= 1){continue;}
    			$remaining_words .= ' ' . $word;
    		}
    		$title = '<span class="home_widget"><span class="home_widget_lc">' . $title_array[0] . ' ' . $title_array[1] . '</span>' . $remaining_words . '</span>';
    	}
    	return $title;
    }

    Thread Starter Greg

    (@gadietrich)

    Where do I put this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Modify Widget Titles’ is closed to new replies.