2012-09-20 43 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