To add my personal content into my own endpoint of woocommerce my account page, I need to click on save in permalink setting page.But I would like to avoid this by auto reload this settings.


You should use flush_rewrite_rules function for that.

You have to remember, that this is expensive task, so you should not do it every time the site loads (many tutorials are making such mistake).

Of course you can use it in your plugin activation hook:

register_activation_hook( __FILE__, 'myplugin_flush_rewrites' );
function myplugin_flush_rewrites() {
    // call your rewrite rules registration function here (it should also be hooked into 'init')
  • I have use 'register_activation_hook(FILE, array($wip_final_execute, 'wip_activation'));' after initialize my class and have call 'public function wip_activation(){ flush_rewrite_rules(); }' into my class but how can it save the permalink page? – Rafiq Jul 31 '18 at 6:55
  • 1
    You don't need to save anything. Flush rewrite rules does exactly the same - it flushes rewrite rules stored in DB and recreates them. Just be careful to use activation hook correctly. This question can help you with that: wordpress.stackexchange.com/questions/276476/… – Krzysiek Dróżdż Jul 31 '18 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.