• Resolved ws

    (@ws-craig)


    Quick question I am hoping that you can assist with or at least confirm that this will or will not work the way I am trying to use the plugin.

    I have a post type with a bunch of ajax filtering – The sort order from the plugin works fine here.

    When you click one of the single posts, I am making another ajax call that passes the post ID and loads in the post data in a popover with next/prev arrows to toggle between other posts.

    The way I am currently handling the arrows is in the WP Query for a single post where I then use get_adjacent_post() to get the prev/next post objects.

    
    $next_post = get_adjacent_post(true, '', false, 'category');
    $previous_post = get_adjacent_post(true, '', true, 'category');
    

    From there I build the arrows using

    
    echo '<a href="#" data-target="'. $previous_post->ID .'" class="modal-prev'. $prev .'">';
    echo '<a href="#" data-target="'. $next_post->ID .'" class="modal-next'. $next .'">';
    

    Then in the template I use that data-target attribute to pass the next or previous ID back to the ajax function to load the next post. This is where I am a little hung up as get_adjacent_post() isn’t respecting the sort order from this plugin.

    I know you mention using get_adjacent_post_link() but that isn’t going to necessarily work for me because I really just need the ID’s, not the full permalink.

    Is get_adjacent_post() supposed to work with this custom sort order?

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    I will check this and revert back. I am currently shifting homes and looking at this on my mobile phone

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Is get_adjacent_post() supposed to work with this custom sort order?

    I don’t think so, because these functions do not specify any terms, so WP looks at the current post, queries all the current terms it has and seeks any post that follows within those terms.

    I think it’s simpler to seek the adjacent post from the DB manual sort rank itself. Give me a day or two and I will post a new version with functionality to expose this.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    v2.8.0 now exposes new functionality to retrieve adjacent posts. Please see FAQ #16

    Thread Starter ws

    (@ws-craig)

    Great. Thank you very much for that update. I will test it out shortly. Good luck with the home shifting!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Good luck with the home shifting!

    LOL, ya, painful job!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get_adjacent_post workaround?’ is closed to new replies.