Created
October 7, 2012 01:49
-
-
Save benmay/3846822 to your computer and use it in GitHub Desktop.
Flush WordPress rewrite rules when the MD5 sum of the add post type file changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I put this code in the file where I add my custom post types / taxonomies. | |
// Flush rewrite rules on change of this file. | |
if( get_option('custom_pt_rules') != md5_file( __FILE__ ) ) | |
{ | |
add_action( 'init', function() | |
{ | |
global $wp_rewrite; | |
$wp_rewrite->flush_rules(); | |
}); | |
update_option('custom_pt_rules', md5_file( __FILE__ ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment