Forums

Post Types Order
[resolved] Previous / Next Navigation - Wrong order with get_adjacent_post() (9 posts)

  1. sebchauss
    Member
    Posted 11 months ago #

    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/

  2. nsp-code
    Member
    Plugin Author

    Posted 11 months ago #

    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

  3. sebchauss
    Member
    Posted 11 months ago #

    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...

  4. sebchauss
    Member
    Posted 11 months ago #

    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

  5. nsp-code
    Member
    Plugin Author

    Posted 11 months ago #

    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

  6. sebchauss
    Member
    Posted 11 months ago #

    Hi,

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

  7. sebchauss
    Member
    Posted 11 months ago #

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

  8. Max625
    Member
    Posted 8 months ago #

    @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.

  9. Max625
    Member
    Posted 8 months ago #

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

    Thanks!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.