Last active
November 19, 2018 15:05
-
-
Save avenirer/697e3ae47efc8cf3640a6274ba872431 to your computer and use it in GitHub Desktop.
Debug WordPress 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 debug_rewrite_rules() { | |
global $wp, $template, $wp_rewrite; | |
echo '<pre>'; | |
echo 'Request: '; | |
echo empty($wp->request) ? "None" : esc_html($wp->request) . PHP_EOL; | |
echo 'Matched Rewrite Rule: '; | |
echo empty($wp->matched_rule) ? None : esc_html($wp->matched_rule) . PHP_EOL; | |
echo 'Matched Rewrite Query: '; | |
echo empty($wp->matched_query) ? "None" : esc_html($wp->matched_query) . PHP_EOL; | |
echo 'Loaded Template: '; | |
echo basename($template); | |
echo '</pre>' . PHP_EOL; | |
echo '<pre>'; | |
print_r($wp_rewrite->rules); | |
echo '</pre>'; | |
} | |
add_action( 'wp_head', 'debug_rewrite_rules' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment