WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Custom Post Types. I try this:


add_action( 'admin_init', 'flush_rewrite_rules' );

Now I’d like to remove this again. I try this:

remove_action( 'admin_init', 'flush_rewrite_rules' );

I’m not sure if it works right. How can I test if the rewrite rules really not flushed anymore?

share|improve this question
How did you test if it works? – toscho Oct 6 '12 at 18:51
Can´t test it really, I just try this, too because I get on all my pages 404 errors. I have issues with permalinks and the .htaccess file and I don´t know exactly whats the main bug is. You can see also my other question iyou like:link – ogni Oct 6 '12 at 19:06

To see if the option 'rewrite_rules' was reset – that’s what flush_rewrite_rules() does internally – hook into the option actions and log what happens.

The following small plugin does that. It will tell you what code flushed the rewrite rules and how the rules looked before and after the flush. If no flush happened it just says nothing logged. :)

/* Plugin Name: Debug rewrite rule flushing */

add_action( 'plugins_loaded', 'wpse_67368_debug_rewrite_flushes' );

function wpse_67368_debug_rewrite_flushes()
    static $log = array ();

    if ( 'plugins_loaded' === current_filter() )
        $hooks = array (
        foreach ( $hooks as $hook )
            add_action( $hook, __FUNCTION__, 10, 3 );


    if ( 'shutdown' === current_filter() )
        empty ( $log ) and $log = 'nothing logged';
        printf( '<pre>%s</pre>', var_export( $log, TRUE ) );

    $args = func_get_args();
    $option = array_shift( $args );

    if ( 'rewrite_rules' === $option )
        $log[] = array (
            'filter'    => current_filter(),
            'option'    => $option,
            'args'      => $args,
            'backtrace' => debug_backtrace()
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.