Created
October 25, 2016 23:38
-
-
Save topdown/8b96b9f0f7365e9b991b3102426259d9 to your computer and use it in GitHub Desktop.
For debugging WP rewrite rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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