Skip to content

Instantly share code, notes, and snippets.

@diegoos
Created January 17, 2021 20:43
Show Gist options
  • Save diegoos/08e5ee105aaafcddf35b5cc0f5b707f0 to your computer and use it in GitHub Desktop.
Save diegoos/08e5ee105aaafcddf35b5cc0f5b707f0 to your computer and use it in GitHub Desktop.
Generate table with Wordpress rewrite rules
<?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