【问题标题】:Limit number of images in a nextgen gallery限制下一代画廊中的图像数量
【发布时间】:2014-04-27 23:44:27
【问题描述】:

我正在使用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.']');

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

【问题讨论】:

    标签: wordpress nextgen-gallery


    【解决方案1】:

    您可以尝试以下短代码:

    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 简码,var 2.0 及更高版本:
    http://www.nextgen-gallery.com/nextgen-gallery-shortcodes/

    NextGEN 旧版简码:
    http://www.nextgen-gallery.com/help/shortcodes/

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多