Created
July 16, 2014 08:34
-
-
Save nielsvr/77fe00a9aab4700ba146 to your computer and use it in GitHub Desktop.
Want to get the previous post and next post data 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 | |
/* | |
* Want to get the previous post and next post data in WordPress? Use this in the loop | |
* get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ) | |
*/ | |
$prev_post = get_adjacent_post( false, false, true ); // retrieves previous post in current post type, with no exclusions | |
$next_post = get_adjacent_post( false, false, false ); // retrieves next post in current post type, with no exclusions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment