[英]wordpress: problem with adding another rule with wp_rewrite
i set my wordpress permlink to /%category%/%postname%
now i'm using Nextgen Gallery so when i have a gallery in a page it will be something like /cat/page?gallery=10
i want to make it something like cat/page/gallery id/
i tried alot with wp_rewrite ... but no luck ... any help ? 我将我的wordpress permlink设置为
/%category%/%postname%
现在我正在使用Nextgen Gallery所以当我在页面中有一个画廊时它会像/cat/page?gallery=10
我想让它像cat/page/gallery id/
我尝试了很多wp_rewrite ...但没有运气......任何帮助?
this is what i'm testing on .. it's not my code it's provided from wordpress ... i will put everything in its place when i found the way ... so don't worry i will not flushRules
on init
... thanks a lot 这就是我正在测试...它不是我的代码它是由wordpress提供的...当我找到方法时我将把所有东西放在它的位置...所以不要担心我不会在
init
flushRules
...非常感谢
add_filter('rewrite_rules_array','wp_insertMyRewriteRules');
add_filter('query_vars','wp_insertMyRewriteQueryVars');
add_filter('init','flushRules');
// Remember to flush_rules() when adding rules
function flushRules(){
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
// Adding a new rule
function wp_insertMyRewriteRules($rules)
{
$newrules = array();
//i don't know what should i put here
$newrules[''] = '';
return $newrules + $rules;
//
}
// Adding the id var so that WP recognizes it
function wp_insertMyRewriteQueryVars($vars)
{
array_push($vars, 'id');
return $vars;
}
Hope this 2 URL points you on the right direction: 希望这2个URL指向正确的方向:
Perhaps a Google keyword search will save you a lot of time... :) 也许Google关键字搜索会为您节省大量时间...... :)
Regards. 问候。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.