在第一张图片之后,在Wordpress的图库简码中添加摘录


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++ ?>

任何指导将不胜感激。

最终发现这对我有用。刚刚将其添加到我的函数.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' );