Support » Developing with WordPress » 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

    (@bcworkz)

    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.