在短代码wordpress中插入多个短代码

我是php的新手, 想知道如何使用shortcode插入多个shortcode
所需的结果看起来像这样

[logo_section_2 section-title="1" section-title-text="WE SHARE THE SAME CULTURE" logos-second-row="true"] [logo_images logo-id="1" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-swiss.png"] [logo_images logo-id="2" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-hudson.png"] [logo_images logo-id="3" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-twitter.png"] [logo_images logo-id="4" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-index.png"] [logo_images logo-id="5" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-reed.png"] [logo_images logo-id="6" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-viagogo.png"][logo_images_2 logo-id="4" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-index.png"] [logo_images_2 logo-id="5" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-reed.png"] [logo_images_2 logo-id="6" logo-image-source="http://localhost:8888/signal-theme-export/wordpress/wp-content/uploads/2016/07/logo-viagogo.png"]

[/ logo_section_2]
这样我就可以添加多行图像
我的PHP如下
< ?php

add_shortcode(‘ logo_section_2’ , ‘ logo_section_2’ ); 函数logo_section_2($ atts, $ content =” ” ){shortcode_atts(array(‘ section-title’ => false, ‘ section-title-text’ => ” , ‘ logos-second-row’ => false, / / … ..), $ atts);
$output = ''; $output .= '< div class="logo-section clearfix"> '; $output .= '< div class="logo-section--inner clearfix"> '; if ($atts['section-title'] == true) { $output .= '< h2 class="heading--small heading--bold heading--uppercase heading--sans-serif heading--center heading"> '. $atts['section-title-text'] .'< /h2> '; } else { $output .= ''; }$output .='< div class="logo-section--row clearfix"> ' . do_shortcode($content) . '< /div> '; if ($atts['logos-second-row'] == 'true') { $output .='< div class="logo-section--row clearfix"> ' . do_shortcode($content) . '< /div> '; } else { $output .= ''; } $output .= '< /div> '; $output .= '< /div> '; return $output;

}
add_shortcode('logo_images', 'logo_images'); function logo_images($atts){ shortcode_atts( array( 'logo-id' => '', 'logo-image-source' => '', 'logo-alt' => '', ), $atts); $output = ''; if($atts['logo-id'] || $atts['logo-image-source']){ $output .= '< img class="logo-'.$atts['logo-id'].'" src="' . $atts['logo-image-source'] . '" /> '; } else { $output .= ''; } return $output; } add_shortcode('logo_images_2', 'logo_images_2'); function logo_images_2($atts){ shortcode_atts( array( 'logo-id' => '', 'logo-image-source' => '', 'logo-alt' => '', ), $atts); $output = ''; if($atts['logo-id'] || $atts['logo-image-source']){ $output .= '< img class="logo-'.$atts['logo-id'].'" src="' . $atts['logo-image-source'] . '" /> '; } else { $output .= ''; } return $output; }

任何帮助都是极好的!
#1我认为你要问的是有关嵌套的短代码的信息……你想触发一个可能包含一个或多个(可变数字)内部项目的UI元素。
这个概念很难解释, 因为它需要将多个代码概念放在一起。但是我会努力的:
  1. 外部简码:
    一个。设置一个全局变量以测试该短代码中是否已有
    b。调用do_shortcode($ content)执行内部短代码
    C。 (内部简码将建立一个全局数组)
    【在短代码wordpress中插入多个短代码】d。使用全局数组上的循环生成完整的UI
    e。返回输出
  2. 内部简码:
    一个。设置要由外部简码使用的全局数组
    b。生成内容并将输出放置在数组项中
    C。返回空白/不输出
并不是那么简单……你需要考虑多个外部短代码调用, 错误嵌套的短代码, 以及是否要处理内层中的非短代码。
看一下这段代码… 也许你可以从中提取一些想法。

    推荐阅读