NextGen gallery并不是建立在自定义帖子类型之上的,因此您无法轻松地将自定义艺术品分类与NextGen链接。最好的办法是在主题中创建存档模板文件,这样可以像NextGen那样显示艺术品。您提到的嵌套方法可以使用hierarchical taxonomies.
例如,您可以创建archive-album.php
使用PHP在主题中创建如下文件:
<?php
// get children of this taxonomy term so we print out folders for them
$this_term = get_queried_object();
$children = get_term_children( $this_term->term_id , \'album\' );
foreach ( $children as $child_term ) {
$child_term = get_term( $child_term , \'album\' );
if ( ! $child_term->count ) continue; // skip terms with no posts in them
// get one random post in this child term
$random_term_post = get_posts( array(
\'posts_per_page\' => 1, // only one post
\'orderby\' => \'rand\', // selected randomly
\'tax_query\' => array(
array(
\'taxonomy\' => \'album\', // from this child album
\'terms\' => $child_term->term_id
)
)
) );
echo \'<a href="\' . get_term_link( $child_term ) . \'">\';
echo get_the_post_thumbnail( $random_term_post[0] ); // show the random post\'s thumbnail
echo $child_term->name;
echo \'</a>\';
}
// now print out all Artwork in this particular term
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- print out Artwork here -->
<?php endwhile; else : ?>
<p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
<?php endif; ?>