Title: Function for widget titles
Last modified: August 17, 2017

---

# Function for widget titles

 *  [jslom](https://wordpress.org/support/users/jslom/)
 * (@jslom)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/function-for-widget-titles/)
 * I am trying to get a function working with a conditional statement if that is
   possible. I can get the function working without the statement..I need it to 
   determine whether or not the widget title is empty and if it is, to ignore the
   function, if it is not, it should use the function below. This function will 
   insert an image as the title using the prefix title_(imagename).png
 * Thank you!
 *     ```
       function html_widget_title( $title ) {
         $output = '<img src="/images/title_'.$title.'.png" alt="'.$title.'" title="'.$title.'"/>';
         return $output;
       }
       add_filter( 'widget_title', 'html_widget_title' );
       ```
   

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/function-for-widget-titles/#post-9423870)
 * Have you tried this:
 *     ```
       if ('' != $title ) {
         // assign image tag to $output
       } else {
         $output = '';
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Function for widget titles’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/function-for-widget-titles/#post-9423870)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
