Home » Php » php – WordPress: list all the URLs / routes

php – WordPress: list all the URLs / routes

Posted by: admin July 12, 2020 Leave a comment


I want to see a list of all the (rewritten) URLs that my WP site is using. Basically, if you’re familiar with Rails, I want rake routes… but for WordPress.

If it matters, the reason is this. I’m writing code to exist next to an existing WordPress site and I keep bumping against a problem where my new code is accessible at the same URL that WordPress or one of it’s plugins is using. I keep having to monkey with the .htaccess file. It would be much easier to just see a list of every URL that’s taken and just avoid them.

How to&Answers:

i’m new to wp, but i think you are after $wp_rewrite

at the right hook do a:

global $wp_rewrite;  

if nothing is printed, remove ->rules and print whole object

hopefully a starting point 🙂


A similar question was asked over at WordPress Answers, where several helpful suggestions are made, notably the use of a few plugins for this purpose:

Neither have been updated in over 2 years, but I’ve just successfully installed them locally on WordPress 3.7.

Ask Apache’s plugin installs and activates fine, but looks like some of the debugging info is outdated, and otherwise provides more detail than is useful for me.

The Monkeyman Rewrite Analyzer provides a formatted & more interactive representation of [@gwillie's snippet][2]. Works for me!