Seems extremely simple but it doesn't work. Here is my code:

<a href="<?php next_post_link(); ?>">
<button class="btn btn-default pull-right">
<span class="glyphicon glyphicon-arrow-right"></span>

So instead of giving me the next page link, the button has 0 link, I actually have a text next to it with title of the next page and a weird link "localhost:8888/site/next-article-title/a href=" The link is good exceped the "a href" at the end which is weird, but anyway the link is not on the button.

Now if I replace my first line href with a simple http://facebook.com, the link will work and will be on the button as I wish. I must be doing something wrong with the integration of the php link.

Any idea ?

  • if I put href="<?php the_permalink(); ?>" the link works and is on the button as I wish. I'm lost. need some help on this one!
    – Simba
    Oct 24, 2014 at 0:42

1 Answer 1


next_post_link() actually creates an anchor tag, not just the URL.

Try something like below to just get the URL:

<?php echo get_permalink(get_adjacent_post(false,'',true)); ?>
  • Works flawlessly. I was stuck on this "simple" thing for the past 3 hours literally so I owe you a big thank you ! Thanks a lot man.
    – Simba
    Oct 24, 2014 at 2:18

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.