Last active
September 20, 2017 05:03
-
-
Save manchumahara/f6a6e94289a30842d0ec1bc5262ed254 to your computer and use it in GitHub Desktop.
Wordpress adjacent next previous sort sql filter example http://codeboxr.com/product/show-next-previous-article-for-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
add_filter('get_next_post_sort', 'cbx_custom_get_next_post_sort', 10, 2); //first param query, 2nd param $post object | |
add_filter('get_previous_post_sort', 'cbx_custom_get_previous_post_sort', 10, 2); //first param query, 2nd param $post object | |
/** | |
* Filter get next adjacent post sort sql | |
* | |
* @param $sort_sql | |
* @param $post | |
* | |
* @return mixed | |
*/ | |
function cbx_custom_get_next_post_sort($sort_sql, $post){ | |
//$sort_sql = "ORDER BY p.post_date $order LIMIT 1"; | |
//modify the sort sql as need | |
return $sort_sql; | |
} | |
/** | |
* Filter previous adjacent post sort sql | |
* | |
* @param $sort_sql | |
* @param $post | |
* | |
* @return mixed | |
*/ | |
function cbx_custom_get_previous_post_sort($sort_sql, $post){ | |
//$sort_sql = "ORDER BY p.post_date $order LIMIT 1"; | |
//modify the sort sql as need | |
return $sort_sql; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment