質問: null ) { extract( shortcode_atts( array( 'class' => '', 'id' => '', ), $atts ) ); return '<div id="' . $id . '" class="' . $class . '">' . $content . '</div>'; } add_shortcode('button', 'project_shortcode'); これは私が欲しい出力です:<div class="container item"> <div class="row"> <div class="intro twelvecol"> <div class="top-border"></div> </div> <div class="screenshot eightcol"> <img src="<?php bloginfo( 'template_url' ); ?>/images/studyatbest.png"> </div> <div class="screenshot fourcol last"> <h3>best language center</h3> <p>best language center is an educational establishment in taichung, taiwan. i was asked to build and design a website they could use to offer classes, programs and display photos online.</p> <ul> <li> <h4>role</h4> <p>design, html/css, javascript</p> <li> <h4>year</h4> <p>2010</p> </li> <li> <h4>website</h4> <p><a href="http://studyatbest.com/">studyatbest.com</a></p> </li> </ul> </div> </div> </div> しかし、コードをきれいに保つために、ショートコードで複数の行を返すことができるようにするにはどうすればよいかわかりません。助言がありますか?
回答: とった:// project shortcode function project_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'client' => '', 'screenshot' => '', 'role' => '', 'year' => '', 'website' => '', ), $atts ) ); ob_start(); ?> <div class="container item"> <div class="row"> <div class="intro twelvecol"> <div class="top-border"></div> </div> <div class="screenshot eightcol"> <img src="<?php bloginfo( 'template_url' ); ?>/images/<?php echo $screenshot ?>"> </div> <div class="screenshot fourcol last"> <h3><?php echo $client ?></h3> <p><?php echo $content ?></p> <ul> <li> <h4>role</h4> <p><?php echo $role ?></p> <li> <h4>year</h4> <p><?php echo $year ?></p> </li> <li> <h4>website</h4> <p><a href="http://<?php echo $website ?>"><?php echo $website ?></a></p> </li> </ul> </div> </div> </div> <?php return ob_get_clean(); } add_shortcode('project', 'project_shortcode'); (そのコードに悪い習慣があるかどうか教えてください)。