[英]Wordpress previous post shortlink
Hey guys so far I have this code that gives me the full link to my previous post 嗨,到目前为止,我有这段代码可以为我提供以前文章的完整链接
<?php $prevPost = get_previous_post(FALSE);
if($prevPost) {?>
<div class="prev1" onclick="javascript:_gaq.push(['_trackSocial', 'Nav', 'Prev-Thumb']);">
<?php previous_post_link('%link',"«", FALSE); ?>
</div>
<?php } ?>
But I want the shortlink instead of the full link 但是我想要短链接而不是完整链接
How can I accomplish that ? 我该怎么做?
Thank you in advance 先感谢您
Swap out your existing code with the following. 用以下代码交换您现有的代码。
<?php
// Get the previous post.
$previous_post = get_previous_post();
// Check a post was found.
if ( $previous_post ) : ?>
<div class="prev1" onclick="javascript:_gaq.push(['_trackSocial', 'Nav', 'Prev-Thumb']);">
<a href="<?php echo wp_get_shortlink( $previous_post->ID ); ?>" title="Permalink to previous post">«</a>
</div>
<?php endif; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.