2016-01-28 71 views
0

可以說我有一個URI這就是portfolio_categories/guttersspouting/WordPress的重新寫入規則

我怎麼可以重寫的功能來改變它太"products"

+0

它只是這個網址或分類標準什麼的? – David

+0

@David Page URL :) –

回答

1

確定的要求這個URI「產品」完全匹配。如果向第三方發佈代碼就好像他們創建了一個名爲product的頁面,這是不可取的,它將遵循此規則。

順便說一句,我假設你的意思post_type =頁面(也將工作職位,看到post_id=在add_rewrite_rule?你需要改變這要重定向到頁面的帖子ID。

add_action('init', 'new_rewrite_rule'); 
function new_rewrite_rule(){ 
    // matches product exactly, product/aproduct will fail, etc 
    // you need to add your own post_id into the function below. 
    add_rewrite_rule('^product$','index.php?page_id=12','top'); 
} 

您將需要刷新重寫規則這個工作(去固定鏈接設置頁面,只需點擊保存按鈕)

代碼版本的沖洗重寫規則,不要讓它在wp_loaded運行是一個好主意,應該在激活掛鉤真的,但爲了測試,這將做到:

function new_flush_rewrite_rules() { 

    flush_rewrite_rules(); 
} 

add_action('wp_loaded', 'new_flush_rewrite_rules'); 

只需要注意,您也可以在帖子編輯屏幕中手動執行此操作。