0
是否可以在do_shortcode()函數內運行循環?如何在WordPress do_shortcode()函數中運行循環?
實施例:
echo do_shortcode('[iscorrect]'.$text_to_be_wrapped_in_shortcode.'[/iscorrect]');
http://codex.wordpress.org/Function_Reference/do_shortcode
我試圖創建一個函數,以獲得數據並把它粘在陣列中。然後對於該數組中的每個項目,返回單個數組值。
實施例:
function the_ips(){
$ips = get_ips();
foreach($ips as $ip){
return $ip;
}
}
我已轉儲的數據陣列,以確保它具有在其內的正確的數據。一切都是正確的。它繼續在do_shortcode()函數內輸出數組的第一個值,但沒有其他值。
這是我曾嘗試:
echo do_shortcode('[iscorrect]'.the_ips().'[/iscorrect]');
或
$content = '';
$content .= '[iscorrect]';
$ips = get_ips();
foreach($ips as $ip){
$content .= $ip;
}
$content .= '[/iscorrect]';
echo do_shortcode($content);
它仍然繼續生產的陣列,別無其他的第一個結果。
最後,我想在一個有序列表返回每個IP作爲一個列表項。 – 2012-03-01 16:43:08
@MichaelEcklund更新示例 – menacingly 2012-03-01 16:49:51