Wordpress后导航缩略图链接

时间:2017-04-04 15:03:36

标签: wordpress

我有以下代码显示WordPress帖子导航,但只有标题链接到帖子。有没有办法让整个事情链接到帖子呢?

previous_post_link( '<div class="prev">'.$prevThumbnail.'<div class="prev-post-header">Previous</div>%link</div>', '%title' );

1 个答案:

答案 0 :(得分:0)

https://codex.wordpress.org/Function_Reference/get_previous_post https://codex.wordpress.org/Function_Reference/get_next_post

<?php
$prev_post = get_previous_post();
$next_post = get_next_post();
if (!empty( $prev_post )): ?>
    <a href="<?php echo $prev_post->guid ?>">
        <?php echo get_the_post_thumbnail( $prev_post->guid, 'thumbnail' ); ?>
        <?php echo $prev_post->post_title ?>
    </a>
<?php endif;
if (!empty( $next_post )): ?>
    <a href="<?php echo esc_url( get_permalink( $next_post->ID ) ); ?>">
        <?php echo get_the_post_thumbnail( $next_post->ID, 'thumbnail' ); ?>
        <?php echo esc_attr( $next_post->post_title ); ?>
    </a>
<?php endif; ?>