After calling an update_option(‘permalink_structure’, ‘/%postname%/’) via script in functions.php, is it necessary to then call a $wp_rewrite as indicated below?
// Flush rules to pick up the new page.
$wp_rewrite->init();
$wp_rewrite->flush_rules();
If so, it the purpose of the rewrite to insure that the .htaccess file gets updated?
I ask this because just after executing the function, my pages return 404’s even though the permalinks_options.php reports that the permalink is indeed set to custom: ‘/%postname%/’)
However, I have to manually hit “Save Changes” on the permalink options page to make it stick. I’m wondering if the fix is to add the rewrite code above, or am I missing something?