限制nextgen图库中的图像数量

时间:2014-04-27 14:11:22

标签: wordpress nextgen-gallery

我正在使用WordPress的nextgen图库插件。我正在制作一个页面,我希望通过id获取nextgen图库并将其中的图像数量限制为2.我用来获取图库的代码是:

$post_id = get_the_ID();
$gallery = get_post_meta (get_the_ID(), 'Gallery', false);
$successes = $gallery[0]; /* Where $array is the variable holding the result */
$gallery_id= $successes[0];
echo do_shortcode('[nggallery id='.$gallery_id.']');

图库中有六个图像,它们用于原始帖子。这只是一个旅游帖子,所以我想在这里限制图片的数量。这可能吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试以下短代码:

<强> 1

echo do_shortcode("[nggallery id=$gallery_id images=2]");

images参数控制显示的图像数量。 0表示全部显示。您还将获得一些分页链接以浏览图库的图像。我没有找到隐藏它们的选项,所以如果它们是不必要的,你可以通过css(display: none)隐藏它们。

<强> 2

echo do_shortcode("[random max=2 id=$gallery_id]");

从您的图库中显示随机最多2张图片。


我还建议以下链接:

NextGEN Gallery Shortcodes,var 2.0及以上:
http://www.nextgen-gallery.com/nextgen-gallery-shortcodes/

NextGEN Legacy Shortcodes:
http://www.nextgen-gallery.com/help/shortcodes/

未记载的NextGEN Gallery短代码:
http://www.ralph-kemps.eu/2013/03/19/undocumented-nextgen-gallery-shortcodes/