Joy
(@joyously)
Changing the rewrites should not be in a theme. It makes it so you don’t want to change themes (theme lock-in). Please, if this theme is in the WordPress repository, please report it, as it is violating the Theme Requirements.
The problem you are seeing could be due to the execution order. Themes are last to load and the activation code could easily be running in the context of the old theme instead of the new one. (another reason this sort of thing doesn’t belong in a theme)
Thread Starter
dewd
(@dewd)
Don’t worry, this isn’t anywhere in the open market, neither will it ever be. It’s at the behest of a private client. A theme has been built specifically for their purposes.
The reason we want the default permalink to be the post name is because WordPress and the theme are deployed to multiple environments and sometimes get reinstalled from scratch. Automating the permalink change just removes a manual process.
WordPress used to automate this rewrite to .htaccess
and web.config
on install, defaulting permalinks to post name. It now defaults to post id.
It is highly unlikely this is to do with the running order, since it’s something which works with the htaccess
config file in a *nix environment, but not the web.config
file in a Windows environment (my problem).
P.S. Just to politely clarify, this action does not cause theme lock in. All it does is automates the manual action of changing permalinks under settings. Manually changing permalinks using the default interface, under settings updates the rewrites in either htaccess
or web.config
as appropriate. It’s a core WordPress process. I just don’t know why it works on Windows with a manual update and not an automated one as documented by WordPress.
Joy
(@joyously)
WordPress used to automate this rewrite to .htaccess and web.config on install, defaulting permalinks to post name. It now defaults to post id.
No, WordPress has always defaulted to post id as the “ugly” permalink. The default “pretty” permalink is the date and post name.
https://codex.wordpress.org/Using_Permalinks
Manually changing permalinks using the default interface, under settings updates the rewrites in either htaccess or web.config as appropriate.
Well, no, the file is only written when it needs to. It’s the internal rewrites that are recomputed.
You might follow through the code here:
https://developer.wordpress.org/reference/functions/iis7_save_url_rewrite_rules/