Created
January 17, 2021 20:43
-
-
Save diegoos/08e5ee105aaafcddf35b5cc0f5b707f0 to your computer and use it in GitHub Desktop.
Generate table with Wordpress rewrite rules
This file contains hidden or 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 pretty_routes() | |
{ | |
$wp_rewrite = new WP_Rewrite; | |
$rules = $wp_rewrite->rewrite_rules(); | |
$table = '<table><tr><th>Route</th><th>Destination</th></tr>'; | |
foreach ($rules as $route => $dest) { | |
$table .= "<tr><td>{$route}</td><td>{$dest}</td></tr>"; | |
} | |
$table .= '</table>'; | |
return $table; | |
} | |
echo pretty_routes(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment