I changed permalinks in wp_options table in database and I’m getting 404 on every post. Everything works fine after I log in into the panel and click “save settings” on permalinks options page.
How to do this automatically (ie. “refresh” those settings)?
Add
flush_rewrite_rules();
to your theme’sfunctions.php
, load the page, and them remove it. It is very inefficient to have that run on every page load.Hopefully your edits to the options table are sane. If not, that will not work.
Caveat: I think that
functions.php
is adequate. You may need to add it to a plugin or a mu-plugin file if that does not work correctly.If you’re writing a plugin, you should use this during activation, deactivation and uninstall. More info in that answer, but a quick example here.
Just keep in mind that you should NOT do it on every page load/request!.