[Plugin: Post Types Order] Previous / Next Navigation – Wrong order with get_adjacent_post()
-
Versions :
WP 3.3.2
Advanced Post Types Order 2.5.0.3.1Problem :
The posts I get from the get_adjacent_post() function in single.php don’t respect the order defined with your plugin.I saw that the code bellow is commented in your plugin :
//add_filter('get_previous_post_where', 'cpto_get_previous_post_where'); //add_filter('get_previous_post_sort', 'cpto_get_previous_post_sort'); //add_filter('get_next_post_where', 'cpto_get_next_post_where'); //add_filter('get_next_post_sort', 'cpto_get_next_post_sort');
And the matching handler functions don’t exist. Why it isn’t done ?
I put this code in my functions.php to correct this but it doesn’t manage the selected post types in your plugin :
function theme_adjacent_previous_post_sort() { return 'ORDER BY p.menu_order DESC LIMIT 1'; } add_filter('get_previous_post_sort', 'theme_adjacent_previous_post_sort'); function theme_adjacent_previous_post_where() { global $wpdb; global $post; return $wpdb->prepare('WHERE p.menu_order < %s AND p.post_type = %s AND p.post_status = "publish"', $post->menu_order, $post->post_type); } add_filter('get_previous_post_where', 'theme_adjacent_previous_post_where'); function theme_adjacent_next_post_sort() { return 'ORDER BY p.menu_order ASC LIMIT 1'; } add_filter('get_next_post_sort', 'theme_adjacent_next_post_sort'); function theme_adjacent_next_post_where() { global $wpdb; global $post; return $wpdb->prepare('WHERE p.menu_order > %s AND p.post_type = %s AND p.post_status = "publish"', $post->menu_order, $post->post_type); } add_filter('get_next_post_where', 'theme_adjacent_next_post_where');
https://www.ads-software.com/extend/plugins/post-types-order/
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘[Plugin: Post Types Order] Previous / Next Navigation – Wrong order with get_adjacent_post()’ is closed to new replies.