Created
October 10, 2014 18:43
-
-
Save hasinhayder/afdf0eb8240d4475691d to your computer and use it in GitHub Desktop.
Getting link for next and previous post in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tb_get_previous_post_link(){ | |
global $post; | |
$prev_link = ""; | |
$prev_post = get_previous_post(); | |
if($prev_post){ | |
$prev_link = get_the_permalink($prev_post->ID); | |
} | |
return $prev_link; | |
} | |
function tb_get_next_post_link(){ | |
global $post; | |
$next_link = ""; | |
$next_post = get_next_post(); | |
if($next_post){ | |
$next_link = get_the_permalink($next_post->ID); | |
} | |
return $next_link; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment