Powered By Blogger

Monday, January 23, 2017

How to flush rewrite rules on the activation of any plugin OR Permalink update programmatically

http://wordpress.stackexchange.com/questions/36306/how-do-i-programmatically-force-custom-permalinks-with-my-theme





global $wp_rewrite; 

//Write the rule
$wp_rewrite->set_permalink_structure('/%postname%/'); 

//Set the option
update_option( "rewrite_rules", FALSE ); 

//Flush the rules and tell it to write htaccess
$wp_rewrite->flush_rules( true );




http://wordpress.stackexchange.com/questions/143801/how-to-flush-rewrite-rules-on-the-activation-of-any-plugin

 /** *Auto permalink re-save */
function wpd_add_rewrite_rules(){
 global $wp_rewrite;
 $wp_rewrite->flush_rules();
 }
add_action( 'init', 'wpd_add_rewrite_rules' );

No comments:

Post a Comment