du0531 2010-11-24 20:48
浏览 39
已采纳

wordpress:使用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 ?

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

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;
}
  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改