Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress: list all the URLs / routes

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.

like image 224
emersonthis Avatar asked Sep 26 '13 12:09

emersonthis


2 Answers

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

at the right hook do a:

global $wp_rewrite;  
print_r($wp_rewrite->rules);

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

hopefully a starting point :)

like image 172
gwillie Avatar answered Oct 04 '22 21:10

gwillie


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:

  • http://wordpress.org/extend/plugins/monkeyman-rewrite-analyzer/
  • http://wordpress.org/plugins/askapaches-rewriterules-viewer/

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!

like image 22
ptim Avatar answered Oct 04 '22 23:10

ptim