I am trying to set permalink structure on theme activation. The following function included in function.php of theme.
// Executes function on theme activation
function myactivationfunction() {
global $wp_rewrite;
$wp_rewrite->set_permalink_structure( '/%category%/%postname%/' );
// register taxonomies/post types here
flush_rewrite_rules();
}
add_action("after_switch_theme", "myactivationfunction", 10 , 2);
This code works correctly but value not writing into .htaccess or .htaccess not creating. How can i write .htaccess file dynamically?
Any help would be greatly appreciated.
Thanks
flush_rewrite_rules()
restores the .htaccess rules automatically. These are the same for almost all rules, so don’t expect to see any changes. Look at the last modified time to see if the file was updated.'/%category%/%postname%/'
. To avoid this need to update .htaccess.