How to get wordpress nav menu outside of wordpress system?

There are a few ways, here’s one:

// no theme output
define('WP_USE_THEMES', false);

// initializes the entire WordPress
require '/path/to/your/wp/wp-blog-header.php';

// here you print your menu
wp_nav_menu('your_theme_menu_location');

Even if theme output is disabled, the theme’s functions.php should still be loaded (and menu locations registered).

You should cache the HTML somewhere within your script, because loading WP just to show a menu can be slow.


see http://codex.wordpress.org/Function_Reference/wp_nav_menu