我有這個網址:WordPress的URL重寫規則
example.com/products-and-services/?catID=5
我想讓它像這樣:
example.com/products-and-services/5
基本上我刪除?catID=
這裏是我的代碼以add_rewrite_rule
這到目前爲止我還沒有運氣:
function custom_rewrite_products() {
add_rewrite_rule('products-and-services/([^/]+)/?$',
'index.php?pagename=products-and-services&catID=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_products')
有什麼建議嗎?
我試過了,沒有工作 –
@ShahGhafoori並以下網址工作= example.com/products-and-services/5/?請確保包含尾部斜線。 – zeropsi