• Hi friends, is it possible to add filter for get_next_post_link & get_next_post_link, if there is no next or last post to display post.

    For example: I restrict it in_same_term, but now if there is no previous or next post it not display any link (because it is a last post in the category).

    I need to display link form any post in the same term or started over the cycle.
    So always to have next or previous link, never only one link?

    Thank you for help.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Yes it is! The filter has a variable tag: "{$adjacent}_post_link"
    The value of {$adjacent} will be either ‘previous’ or ‘next’. Thus to hook it for either possibility you do something like add_filter('next_post_link', 'my_filter_callback', 10, 5 );, then again for ‘previous_post_link’. Whether you can use the same callback or not depends on how your code works. The fifth parameter is the value of $adjacent so your code knows which way the user is going.

    The rest of the parameters passed are described in the inline docs.

Viewing 1 replies (of 1 total)
  • The topic ‘get_next_post_link to cycle last post’ is closed to new replies.