【发布时间】:2018-05-05 07:23:05
【问题描述】:
我正在开发一个自定义投资组合模板页面,以显示所有带有画廊的帖子。由于一些画廊有很多图片,我想折叠它们以最大限度地减少页面滚动。
在页面加载时,在网格中显示第一行缩略图的最佳方式是什么,然后单击“加载更多”按钮以显示剩余的缩略图?
我正在尝试关注 WP 的 get_post_gallery() 函数,但不知道如何告诉它只加载前几个缩略图,然后单击加载更多。如果我能以某种方式利用 Bootstrap 3 的折叠/展开代码,那就太好了,因为我正在网站上使用该框架。
包括我想要实现的目标的模型: View Mockup
https://codex.wordpress.org/Function_Reference/get_post_gallery
<?php
/* The loop */
while ( have_posts() ) : the_post();
if ( get_post_gallery() ) :
$gallery = get_post_gallery( get_the_ID(), false );
/* Loop through all the image and output them one by one */
foreach( $gallery['src'] as $src ) : ?>
<img src="<?php echo $src; ?>" class="my-custom-class" alt="Gallery image" />
<?php
endforeach;
endif;
endwhile;
?>
【问题讨论】:
标签: php html wordpress gallery thumbnails