Skip to content

Instantly share code, notes, and snippets.

@benmay
Created October 7, 2012 01:49
Show Gist options
  • Save benmay/3846822 to your computer and use it in GitHub Desktop.
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.
// 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