2012-09-20 39 views
0

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

感谢您的创意家伙!

回答

0

正则表达式是您的朋友:

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

调整,以满足您的需求。将基础URL定义为一个常量并将此功能封装在一个函数中可能是值得的。

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

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

+0

对不起,我还不够清楚。 next_posts_link()返回http://THECURRENTURL.com/page/x/,这不是一个选项:( – cmplieger