/* Produces a dump on the state of WordPress when a not found error occurs */ /* useful when debugging permalink issues, rewrite rule trouble, place inside functions.php */ ini_set( 'error_reporting', -1 ); ini_set( 'display_errors', 'On' ); echo '
';

add_action( 'parse_request', 'debug_404_rewrite_dump' );
function debug_404_rewrite_dump( &$wp ) {
    global $wp_rewrite;

    echo '

rewrite rules

'; echo var_export( $wp_rewrite->wp_rewrite_rules(), true ); echo '

matched rule and query

'; echo var_export( $wp->matched_rule, true ); echo '

matched query

'; echo var_export( $wp->matched_query, true ); echo '

request

'; echo var_export( $wp->request, true ); global $wp_the_query; echo '

the query

'; echo var_export( $wp_the_query, true ); exit(); }