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条)

报告相同问题?

悬赏问题

  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动