【问题标题】:wordpress: problem with adding another rule with wp_rewritewordpress:使用 wp_rewrite 添加另一个规则的问题
【发布时间】:2011-05-15 08:36:08
【问题描述】:

我将我的 wordpress 永久链接设置为 /%category%/%postname% 现在我正在使用 Nextgen Gallery,所以当我在页面中有一个画廊时,它将类似于 /cat/page?gallery=10 我想让它类似于 cat/page/gallery id/ 我尝试了很多wp_rewrite ...但没有运气...有什么帮助吗?

这就是我正在测试的 .. 它不是我的代码,它是从 wordpress 提供的……当我找到方法时,我会把所有东西都放在它的位置上……所以别担心,我不会 flushRulesinit ...非常感谢

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;
}

【问题讨论】:

  • 我可以建议:wordpress.stackexchange.com - 我希望更多的人知道那里的技术。
  • 我也在那里发帖!! ...我希望有人能帮助我!非常感谢您的建议

标签: php wordpress preg-match


【解决方案1】:

希望这 2 个 URL 为您指明正确的方向:

也许 Google 关键字搜索会为您节省大量时间... :)

问候。

【讨论】:

    猜你喜欢
    • 2012-10-19
    • 2018-11-09
    • 2015-09-09
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 2011-01-13
    • 2019-03-13
    • 2019-12-09
    相关资源
    最近更新 更多