2016-01-28 37 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'); 

只需要注意,您也可以在帖子编辑屏幕中手动执行此操作。