dongpu1908 2013-11-18 05:25
浏览 28
已采纳

如果未在插件激活时设置,则更新永久链接

I need permalink to be set different from default after the plugin is activated I used get_option('permalink_structure') to check if permalink already set or not...

Here is the code block used in plugin activation function , I used class structure

 if (get_option('permalink_structure'))
    {
        $this->setRewriteRules();
        global $wp_rewrite;
        $wp_rewrite->flush_rules(true);
    }

and here is the serRewriteRules function

function setRewriteRules()
{
    add_rewrite_rule('plugin-url/$', '/wp-content/plugins/my-plugin/page.php', 'top');
}

I searched a lot and update my code so many time but still not working for me ....

  • 写回答

1条回答 默认 最新

  • dongyi6845 2013-11-19 06:53
    关注

    rather than changing permalink dynamically you can use generate link from WP permalinks function

    for e.g.

    get_the_permalink()
    the_permalink()
    get_post_type_archive_link()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效