I'm working on a project that ties in an old legacy site with a replacement Wordpress site.

Is there a way I can add a link to a the post navigation to an external link when a user reached the last post in a category?

  • please modify the question, it's hard what you mean by link to a the post navigation to an external link . Use examples what you mean.
    – T.Todua
    Oct 4, 2016 at 19:48

1 Answer 1


Since it's not clear exactly what you need it's hard to give you the best solution.

However ... You should be able to use get_next_posts_link() in your loop template. Or get_previous_posts_link() if that's what you want.

If that returns null you can then echo a link to whereever you want in your template.

if(!get_next_posts_link()) {
    echo '<a href="http://linktosomewhere.com">Continue to somewhere else</a>';

Won't work in custom loops though. Then you have to reference max_num_pages.

if(!get_next_posts_link( 'whatever', $your_query->max_num_pages )) {  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.