質問: null) { extract(shortcode_atts(array( "name" => '', "image" => '', "address" => '', "phone" => '', "email" => '', "website" => '', "description" => '', "amenities" => '' ), $atts)); return '<span class="sort">' if($image) { '<img src="'.$image.'" />'}' <span class="name">'.$name.'</span> <span class="details">' if($phone) { $phone } if($address) { '&bull; <a href="http://maps.google.com/?q='.$address.'" target="_blank">'.$address.' <img src="<?php bloginfo('template_directory'); ?>/_/images/mapmarker.png" width="16" height="16" alt="map" /></a><br/>'} if($email) { '<a class="infomail" href="mailto:'.$email.'">send email</a>' } if($website) { '<a class="infosite" href="'$website'">visit website</a>' } if($description) { '<p class="infodetails">'.$description.'</p>' } if($amenities) { '<p class="amenities">'.$amenities.'</p>' } '</span> </span>'; } add_shortcode("info", "info"); あなたの提案をありがとう!
回答: あなたの条件は文字列の連結を壊します(とにかくあなたのコードにはありません)このセクションを書き直すようにしてください。function info($atts, $content = null) { extract(shortcode_atts(array( "name" => '', "image" => '', "address" => '', "phone" => '', "email" => '', "website" => '', "description" => '', "amenities" => '' ), $atts)); $output = '<span class="sort">'; if($image) { $output .= '<img src="'.$image.'" />';} $output .= '<span class="name">'.$name.'</span> <span class="details">'; if($phone) { $output .= $phone; } if($address) { $output .= ' &bull; <a href="http://maps.google.com/?q='.$address.'" target="_blank">'.$address.' <img src="' . get_bloginfo('template_directory') . '/_/images/mapmarker.png" width="16" height="16" alt="map" /></a><br/>'; } if($email) { $output .= ' <a class="infomail" href="mailto:'.$email.'">send email</a>'; } if($website) { $output .= ' <a class="infosite" href="'.$website.'">visit website</a>'; } if($description) { $output .= '<p class="infodetails">'.$description.'</p>'; } if($amenities) { $output .= '<p class="amenities">'.$amenities.'</p>'; } $output .= '</span> </span>'; return $output; } add_shortcode("info", "info");