Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpress adjacent next previous sort sql filter example http://codeboxr.com/product/show-next-previous-article-for-wordpress
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