Skip to content

Instantly share code, notes, and snippets.

@topdown
Created October 25, 2016 23:38
Show Gist options
  • Save topdown/8b96b9f0f7365e9b991b3102426259d9 to your computer and use it in GitHub Desktop.
Save topdown/8b96b9f0f7365e9b991b3102426259d9 to your computer and use it in GitHub Desktop.
For debugging WP rewrite rules
<?php
function jb_show_rewrite_rules() {
$rules = get_option('rewrite_rules');
$n = 0;
$html = '<table><tr><th style="width: 5%;">#</th><th style="width: 35%;">Key</th><th style="width: 60%;">Rule</th></tr>';
foreach ( $rules as $key => $value ) {
$html .= '<tr><td>' . ++$n . '</td><td>' . $key . '</td><td>' . $value . '</td></tr>';
} // end foreach
$html .= '</table>';
echo $html;
}
// Something like this for quick and dirty
add_action('wp_head', 'jb_show_rewrite_rules');
// Or run the funtion where you want to see the data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment