Undefined variable WordPress Shortcode

I’m having a hard time trying to get a shortcode working for my WP theme. I keep getting this error:

Notice: Undefined variable: output in ……..wp-contentpluginssunland-shortcodesV2includesshortcode-functions.php on line 119

Read More

Here is the code for the shortcode that I’m creating.

if( !function_exists('bizbox_shortcode') ) {
function bizbox_shortcode($atts, $content = NULL) {
extract(shortcode_atts(array(
    "image" => '',
    "description" => '',
    "title" => 'Business Name',
    "address" => '123 Main St. Chula Vista Ca.',
    "phone" => '(619)555-1234',
   ), $atts) );

$output .= '<div class="bizbox clearfix">';
if ( $image ) { $output .= '<div class="bizthumb"><img src="'. $image .'" alt="Visit our friends close by" /></div>'; }
$output .= '<div class="bizdesc">';
$output .= '<h2>'. $title .'</h2>';
$output .= ''. $address .' <br />';
$output .= $phone;
if ( $description ) { $output .= '<p>'. $description .'</p>'; }
$output .= '</div></div>';
return $output;
}}
add_shortcode('bizbox', 'bizbox_shortcode');

Line 119 would be the first $output line. Any help is much appreciated.

Related posts

Leave a Reply

1 comment

  1. Remove the . before the $output variable the first time it appears.
    Rewrite as

    $output = '<div class="bizbox clearfix">';
    if ( $image ) { 
     $output .= '<div class="bizthumb"><img src="'. $image     .'" alt="Visit our friends close by" /></div>'; }
     $output .= '<div class="bizdesc">';
     $output .= '<h2>'. $title .'</h2>';
     $output .= ''. $address .' <br />';
     $output .= $phone;
     if ( $description ) { $output .= '<p>'. $description .'</p>'; }
     $output .= '</div></div>';
    return $output;
    

    `