• Resolved sebchauss

    (@sebchauss)


    Versions :
    WP 3.3.2
    Advanced Post Types Order 2.5.0.3.1

    Problem :
    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');

    http://wordpress.org/extend/plugins/post-types-order/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author nsp-code

    (@nsp-code)

    Hi,
    For a faster support please contact us through the help at nsp-code.com It appear the version you use is different for some reason.

    Thank you

    Thread Starter sebchauss

    (@sebchauss)

    Hi,

    I don’t see any help section on your website! I know that this is the support for the free version but I really need your help.

    For my issue, I found the handler functions and so I have uncommented the 4 “add_filter”. I got a lot of php error because the parameters are not sent to the function so I put :

    advanced-post-types-order.php, line 189

    add_filter('get_previous_post_where', 'cpto_get_previous_post_where', 10, 3);
    add_filter('get_previous_post_sort', 'cpto_get_previous_post_sort');
    add_filter('get_next_post_where', 'cpto_get_next_post_where', 10, 3);
    add_filter('get_next_post_sort', 'cpto_get_next_post_sort');

    include/functions.php, line 377

    function cpto_get_previous_post_where($where, $in_same_cat, $excluded_categories)

    include/functions.php, line 464

    function cpto_get_next_post_where($where, $in_same_cat, $excluded_categories)

    That’s better but I still have errors…

    Thread Starter sebchauss

    (@sebchauss)

    Hi again,

    The remaining errors are caused by $posts_in_ex_cats_sql which isn’t defined at the lines 449 and 537.

    Do you have a quick solution ? Thank you

    Plugin Author nsp-code

    (@nsp-code)

    Hi,
    Un-comment the filters you see in your code will not work, instead please use the last plugin version which currently is 2.5.0.5

    Thank you

    Thread Starter sebchauss

    (@sebchauss)

    Hi,

    I’ll try it as soon as possible. Thank you.

    Thread Starter sebchauss

    (@sebchauss)

    This this alright with this new version. Thank you for your reactivity.

    @sebchauss – thanks for this post. Can you clarify what your final solution was? I think I have the same problem – need the next post/previous post navigation to follow the order specified with this plugin. I can’t seem to get it to work for single page template – while the archive and category templates (which use wp-paginate plugin) works perfectly.

    Glad to start my own post if this seems off-topic, but I think you have the solution I need.

    Thanks.

    Excuse my ignorance – the answer is right here
    Previous / Next Navigation – Wrong order

    Thanks!

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.