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()
使用未记录的函数get_next_posts_page_link()
来返回实际的URL,因此假设下一页存在,您可以使用它而不是尝试从get_next_posts_link()
的返回中提取URL。
Use below function for next and previous URL instead of get_next_posts_link() and get_prev_posts_link
$next_link = get_permalink(get_adjacent_post(false,'',false));
$prev_link = get_permalink(get_adjacent_post(false,'',true));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.