It seems like others have experienced similar issues as me in the past on this subject, but nobody has provided a complete answer.
I’m attempting to run a PHP script to update the permalink structure in the wp_options
table for a slew of WordPress blogs. I want to connect to each database and update the permalinks without having to log in to each blog and update the setting through the UI.
I’m successful at connecting to the DB and updating the permalink_structure
field with the proper codes, but it causes a 404 when attempting to view any posts.
Is WordPress updating other tables/fields to fully enable the permalink?? I’m having a hard time finding the complete answer to this.
BTW: If there are edits being made to the .htaccess
when this is done through the WordPress UI, I’m not seeing it. The htaccess looks unchanged when I do this through the UI.
Thanks!
WordPress permalink rewrite_rules are kinda troublesome. They are great if you wanna do basic stuff, but it’s damn hard to do some complex rules with it.
What exact structure you wanna use?
Remember that htaccess created by WordPress just redirects everything to index.php, which loads WordPress system (wp_load()), and one of its components parses REQUEST_URI.
First it tries to to bind REQUEST_URI into one of its regexes, which makes it understand what kind of resource is being requested (category, tag, page, post, etc), then it tries to find which resource it is (if it’s a post, find which post by it’s slug).