1
我需要使用wordpress与标准的重写规则,如“http://www.mysite.com/?p=123” ,但我想重写内容像“http://www.mysite.com/store”,但我不想使用WordPress的内部功能,如“http://www.mysite.com/postname” ,我将重写在.htacess中,所以我写了这样的内容被rewrited,WordPress的使用标准重写,然后设置功能做重写page_id
function replace_mycontent($string){
$pattern = '/?page_id=([^/]+)/'; // urls like http://www.mysite.com/?p=123
$replacement = '/$1/'; // gets replaced by http://www.mysite/store
return preg_replace($pattern, $replacement, $string);
}
add_filter('the_content', 'replace_mycontent');
这给了错误,一些帮助欢迎,
谢谢!
不工作,我认为问题出现了,在标准模式wordpress中为/?p = 123,但一直重写为/?page_id = 123,那么在内容中搜索什么?我只是想重写/?p = 123或/?page_id = 123来存储,而不是像这样的www.mysite/store结束斜线。 – user1391670
检查编辑答案。你可能会发现任何线索。 – Vishal
我测试过并且没有什么好处,我认为这个函数没有被使用,代码是在一个插件里面,是插件里面的唯一代码,也许是缺少的东西。 – user1391670