我已经成功地使用以下代码显示了next&;的缩略图;以前的链接用于普通帖子,但这对于自定义帖子类型根本不起作用。
<div id="cooler-nav" class="navigation">
<?php $prevPost = get_previous_post(true);
if($prevPost) {?>
<div class="nav-box previous">
<?php $prevthumbnail = get_the_post_thumbnail($prevPost->ID, \'tiny_thumb\' );?>
<?php previous_post_link(\'%link\',"$prevthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php } $nextPost = get_next_post(true);
if($nextPost) { ?>
<div class="nav-box next">
<?php $nextthumbnail = get_the_post_thumbnail($nextPost->ID, \'tiny_thumb\' ); } ?>
<?php next_post_link(\'%link\',"$nextthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php ?>
</div><!--#cooler-nav div -->
我猜这一定是一个特殊的查询来查找我的自定义帖子类型“公文包”
任何帮助都将不胜感激
编辑
<nav class="clearer">
<?php if( $prev_post = get_previous_post() ): ?>
<?php echo $prev_post->ID ?>
<div class="nav-box previous">
<?php $prevthumbnail = get_the_post_thumbnail($prev_post->ID, \'tiny_thumb\' );?>
<?php previous_post_link(\'%link\',"$prevthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php endif; ?>
<?php if( $next_post = get_next_post() ): ?>
<?php echo $next_post->ID ?>
<div class="nav-box next">
<?php $nextthumbnail = get_the_post_thumbnail($next_post->ID, \'tiny_thumb\' ); ?>
<?php next_post_link(\'%link\',"$nextthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php endif; ?>
</nav>
其他循环不起作用(我得到缩略图和链接,但不排除当前帖子或随机排序)
<?php
$t_args = array (
\'tax_query\' => array (
array (
\'orderby\' => \'rand\',
\'post_type\' => \'portfolio\',
\'taxonomy\' => \'service\',
\'field\' => \'slug\',
\'terms\' => $service_type,
\'post__not_in\' => array($post->ID)
)
)
);
$query = new WP_Query( $t_args );
if( $query->have_posts() ) {
while ( $query->have_posts() ) : $query->the_post();
// output your stuff
echo \'<div class="more_from_thumb"><a href="\';
the_permalink();
echo \'">\';
the_post_thumbnail();
echo \'</a></div>\';
endwhile;
wp_reset_query();
} ?>