Last active
January 6, 2022 12:52
-
-
Save johanguse/161acf41f049f6bbe9b5f30f3643fe04 to your computer and use it in GitHub Desktop.
Debug rewrite rules on Wordpress
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
// Debug Rewrite Rules in Wordpress | |
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