2017-08-05 71 views
1

我希望不帶參數的當前網址。WP獲取當前不帶參數的類別網址

例子:

我有這個

http://www.localhost/ajr/gadget/?tri=prix&order=desc 

我想只有這

http://www.localhost/ajr/gadget/ 

我怎樣才能做到這一點?

+0

您必須更改此頁/插件,使用POST調用的邏輯而不是GET調用。 –

+0

感謝您的回覆。我曾經使用交 \t \t \t <選項值= 「?三=大獎賽&順序= ASC」 方法= 「POST」> MOINS謝爾 \t \t \t <選項值= 「?三=大獎賽&順序= desc」 的方法= 「POST」 >加上cher – nicolaswecandoit

回答

0

<option value="?tri=prix&order=asc" method="POST">是沒有意義的,但如果你使用的是形式的地方得到這個頁面,你可以將變量作爲隱藏輸入這樣的:

<input type='hidden' name='tri' value='prix'> 
<input type='hidden' name='order' value='desc'> 
0

感謝您的答覆,但我找到了解決辦法

<?php $current_url = 'http://'; 
$current_url .= $_SERVER['HTTP_HOST']; // Get host 
$path = explode('?', $_SERVER['REQUEST_URI']); // Blow up URI 
$current_url .= $path[0]; // Only use the rest of URL - before any parameters 
echo $current_url;?> 
1

爲什麼不使用:

$current_url = strtok($_SERVER["REQUEST_URI"], '?'); 

以其純bacause它總是沒有?和東西返回一個字符串,(不truefalse)背後?

另一個URL,而不是當前URL:

$some_url = strtok($some_url, '?');