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; ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.