[英]After first image add excerpt within the gallery shortcode for Wordpress
我有一個畫廊,它是使用此短代碼的圖像的滾動集合
[gallery itemtag="div" icontag="span" captiontag="p" link="none" size="full" columns="0"]
畫廊補給的例子:
http://rc2.jaywolfe.com/cars-for-sale/2013-toyota-land-cruiser-base-t30061/
需要在第一張圖片和第二張圖片之間/之后添加內容。 我已經可以在其他應用程序中使用它或它的變體,但是由於它是短代碼,所以我一直在努力獲取它。
<?php $counter = 0; ?>
[gallery itemtag="div" icontag="span" captiontag="p" link="none" size="full" columns="0"]
<?php if ($counter % 4 == 3): /* ADD THIS */ ?>
<div>test</div>
<?php endif; ?>
<?php $counter++ ?>
任何指導將不勝感激。
最終發現這對我有用。 只需將其添加到我的functions.php文件中,然后根據需要調用新的短代碼。
function jw_vdp_gallery() {
ob_start();
$id = get_post_thumbnail_id(get_the_ID()); // gets the post thumbnail ID
echo do_shortcode('[gallery exclude='.$id.' itemtag="div" icontag="span" captiontag="p" link="none" size="full" columns="0"]');
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;
}
add_shortcode( 'vdp-gallery', 'jw_vdp_gallery' );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.