0

在 wordpress中next_posts_link();返回http://currenturl.com/currentpage**/page/x/**. 我可以在functions.php中添加什么以http://baseurl.com/page/x/在所有情况下都返回,所以一个绝对URL而不只是将/page/x/添加到当前页面。

谢谢你们的想法!

4

2 回答 2

0
$url = 'http://' . $_SERVER['SERVER_NAME'] . next_posts_link();

输出:http ://baseurl.com/page/x/

于 2012-09-20T22:49:14.933 回答
0

正则表达式是你的朋友:

$test = 'http://example.com/test';
$test = preg_replace('/^http:\/\/.*?(\/.*)/', "http://baseurl.com$1", $test);
echo $test;

调整以适应您的需要。将基本 url 定义为常量并将此功能封装在函数中可能是值得的。

于 2012-09-20T23:20:48.400 回答