刚刚将我的 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 中可能缺少或不同的内容有任何想法会导致此“[不是有效模板]”消息?