您必须使用wp\\u查询获取除当前帖子外的所有帖子,然后循环浏览并输出其缩略图。
类似这样的东西(应该有效,但未经测试)
<?php
//Set the current page id
$current_id = get_the_id();
// Get all posts of a post type but the current post
$the_query = new WP_Query( array(
\'post_type\' => \'your-post-type\',
//\'post__not_in\' => array( get_the_id() ), Removed to include current post
\'posts_per_page\'=>-1
) );
// The Loop
if ( $the_query->have_posts() ) {
echo \'<ul>\';
while ( $the_query->have_posts() ) {
$the_query->the_post();
if( $current_id == get_the_id() ){
$current = \'active\';
} else {
$current = \'\';
}
echo \'<a class="\'.$current.\'" href="\'.get_permalink( get_the_id() ).\'">\';
echo get_the_post_thumbnail( get_the_id() );
echo \'</a>\';
}
echo \'</ul>\';
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
EDIT: added \'posts_per_page\'=>-1 to the query args
EDIT2: Show the current post with a class of active