Wordpress テーマのスライドショー ショートコードを作成していますが、小さな問題が発生しました。ショートコードはこんな感じ。
[slideshow width=500]
[slide]http://example.com/image1.jpg[/slide]
[slide]http://example.com/image2.jpg[/slide]
[slide]http://example.com/image3.jpg[/slide]
[/slideshow]
したがって、基本的には 2 つの異なるショートコード (スライドショーとスライド) であり、各「スライド」ショートコードの幅を設定する必要があります。親の「スライドショー」ショートコードから「幅」属性を取得し、それを各子「スライド」に渡すにはどうすればよいですか?
//Create slideshow wrapper div
function shortcode_slideshow($atts, $content = null){
$return = '<div class="slideshow">';
$return .= do_shortcode($content);
$return .= '</div><!-- end slideshow -->';
return $return;
}
//Create each slide HTML
function shortcode_slide($atts, $content = null){
$return = '<a class="dolightbox" href="'.$content.'">';
$return .= '<img src="'.$content.'" /></a>';
return $return;
}
add_shortcode('slideshow', 'shortcode_slideshow');
add_shortcode('slide', 'shortcode_slide');