2017-04-04 47 views
0

我有下面的代碼,它顯示WordPress的帖子導航,但只有標題鏈接到帖子。有沒有辦法讓整個事情鏈接到帖子?WordPress的帖子導航縮略圖鏈接

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

回答

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; ?> 
相關問題