1

刚刚将我的 WordPress 网站中的 NextGen Gallery 从 NextGen 版本 1.6.1 升级到 2.0.59

升级后画廊工作正常,但我用来在我的主页上显示四个缩略图的自定义设置不起作用。

我创建了一个自定义主页模板,该模板将显示每个帖子标题和来自相应画廊的四个相关画廊缩略图。

但是,升级后,我看到的不是四个缩略图,而是“[Not a valid template]”

自定义主页代码为:

<ul>
    <?php
    global $post;
    $myposts = get_posts('numberposts=100&order=ASC&orderby=title&category=3');
    foreach($myposts as $post) :
        setup_postdata($post);
    ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a> <?php ngg_excerpt(); ?></li>
    <?php endforeach; ?>
</ul>

我在主题函数中添加了一个自定义函数 ngg_excerpt。该功能在升级后仍然存在,并且具有以下代码:

function ngg_excerpt()
{
    //get the post content
    $content_data = get_the_content();
    //extract shortcode from content
    preg_match("/\[ngg([^}]*)\]/", $content_data ,$matches);
    $results = $matches[1];
    //if shortcode exists in content
    if (!empty($results))
    {
        //extract gallery id from shortcode
        $gallery_id = preg_replace("/[^0-9]/", '', $matches[1]);
        //$template = "gallery-compact.php";
        //make sure that NextGen is loaded
        if (function_exists(nggShowGallery))
        {
            //output gallery, showing only 4 images
            echo nggShowGallery( $gallery_id, "compact", 4 );
        }
    }
}

nggShowGallery 似乎包含在较新版本的 NextGen Gallery 中。是否有人对版本 2.0.59 中可能缺少或不同的内容有任何想法会导致此“[不是有效模板]”消息?

4

3 回答 3

3

通过使用图库 > 其他选项下的重置选项重置图库设置,通常可以解决此问题。

于 2018-07-02T19:07:49.230 回答
1

将您的自定义模板复制到 /wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nggglegacy/view/

于 2014-05-29T03:35:42.817 回答
1

编辑帖子并双击图库。

在那里,在布局部分,选择没有任何服务器路径前缀的模板。

于 2017-08-09T14:49:15.520 回答