-1
我嘗試使用我在線查找的代碼。使用高級自定義字段的自定義圖庫簡碼
詳細:http://www.rinconstrategies.io/custom-gallery-shortcode-for-wordpress.html
我使用並進行調試,我看到問題的解析。
<?php
function create_gallery_view($atts) {
$images = get_field('gallery_view');
$innerHTML = '';
foreach($images as $image) {
$thumb = $image['sizes']['thumbnail'];
$alt = $image['alt'];
$caption = $image['caption'];
$innerHTML .= "<li>
<img src=$thumb alt=$alt />
<p>$caption</p>
</li>";
}
$html = <<<HTML
<ul class="gallery-view-flex">
{$innerHTML}
</ul>
HTML;
echo $html;
}
add_shortcode('gallery_view', 'create_gallery_view');
?>
在我的調試行中有一些問題。
$html = <<<HTML
<ul class="gallery-view-flex">
{$innerHTML}
</ul>
HTML;
echo $html;
我在線閱讀heredoc有這種格式。 但我motivi明白爲什麼調試說解析問題。
有人能幫我理解嗎? 謝謝 Paolo
你永遠不會得到這個答案。誰應該知道你的問題?請嘗試自己瞭解問題的性質,並提出更具體的問題。 –