Skip to content

Instantly share code, notes, and snippets.

@adamrosloniec
Created February 21, 2017 21:13
Show Gist options
  • Save adamrosloniec/e34fcc7a0743769c75db1b072d677946 to your computer and use it in GitHub Desktop.
Save adamrosloniec/e34fcc7a0743769c75db1b072d677946 to your computer and use it in GitHub Desktop.
WordPress - show/debug all rewrites - rewrite dump
function debug_404_rewrite_dump( &$wp ) {
global $wp_rewrite;
echo '<h2>rewrite rules</h2>';
echo var_export( $wp_rewrite->wp_rewrite_rules(), true );
echo '<h2>permalink structure</h2>';
echo var_export( $wp_rewrite->permalink_structure, true );
echo '<h2>page permastruct</h2>';
echo var_export( $wp_rewrite->get_page_permastruct(), true );
echo '<h2>matched rule and query</h2>';
echo var_export( $wp->matched_rule, true );
echo '<h2>matched query</h2>';
echo var_export( $wp->matched_query, true );
echo '<h2>request</h2>';
echo var_export( $wp->request, true );
global $wp_the_query;
echo '<h2>the query</h2>';
echo var_export( $wp_the_query, true );
}
add_action( 'parse_request', 'debug_404_rewrite_dump' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment