dro59505 2013-10-05 20:19
浏览 38
已采纳

刷新后不会更新wordpress中的重写规则

I have added this function to rewrite some rules in wordpress:

add_action( 'init', 'my_add_rewrite_rules' );   

function mydid_add_rewrite_rules() {  

 global $wp_rewrite;    

 add_rewrite_rule(....);        
 .... Added some rewrite rules here...

 $wp_rewrite->flush_rules();

}  

So far, everything works perfect.

After browsing the urls, I supposed that the database containing the rewrite rules was updated and I have commented the line:

// commented the line because this is an "expensive" action and I suppose that the 
// database is already updated
// $wp_rewrite->flush_rules();

However, after commenting, the url rewrite does not work. Why? Wasn't the database already updated?

p.s. I can not flush from the wp admin panel because of some theme's constrains...

Thanks

  • 写回答

3条回答 默认 最新

  • doumu1951 2013-10-08 04:11
    关注

    Ok, found the problem...

    There was another "flush rewrite rules" somewhere else, which actually overriden the database. I commented it as well and everything works fine now.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题
  • ¥15 51单片机显示器问题
  • ¥20 关于#qt#的问题:Qt代码的移植问题