I’m using get_next_posts_link()
for custom paging controls in a WordPress theme. The problem is, the function returns HTML tags and some description text:
<a href="http://localhost/awebsite/page/2/" >Next Page »</a>"><span>Next</span>
All I am interested in is the URL. Is there a core function for taking just the URL? Or will I have to perform a bunch of string functions to trim down the stuff I’m returned?
get_next_posts_link()
uses an undocumented functionget_next_posts_page_link()
to return the actual URL, so assuming that the next page exists, you could perhaps use that rather than trying to extract the URL from the return ofget_next_posts_link()
.Use below function for next and previous URL instead of get_next_posts_link() and get_prev_posts_link