1
Imは、現在、私のワードプレスのショートがある:複数のイメージIDをワードプレスショートコードで処理するにはどうすればよいですか?次のようにwordpressのショートコードを介して複数の画像IDを渡そうとし
[lemonslider images="35,46,43,42,41"]
そして、これは私の機能を以下のように、アイデアは、それがHTMLイメージを返す各画像IDのためでした画像IDの各文字列が、現在それは一つだけを生成します。
// LEMON SLIDER SHORTCODE
function lemon_slider($atts){
$a = shortcode_atts(array(
'images' => '44',
'toshow' => '5',
), $atts);
$SlImages = $a['images'];
$arrlength = count($SlImages);
for($x = 0; $x < $arrlength; $x++) {
$image_attributes = wp_get_attachment_image_src($attachment_id = $SlImages);
return ('<img src=' . $image_attributes[0] . ' width=' . $image_attributes[1] . ' height=' . $image_attributes[2] . ' />');
}
}
add_shortcode('lemonslider', 'lemon_slider');
アイブ氏は、foreach文を見られますが、複数の値を返す方法イムはわかりません。
私の出力は1であり、それはあなたのイメージは、カンマで属性を分割する5.
同じ結果:/ – MrJoshFisher
あなたの結果は何ですか? – beerwin
Nevermind、忘れてしまったこと、私の答えを更新する。 – beerwin