Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Get wordpress menu builder items to display on a different domain WordPress


is there a way to aggregate the menu builder for use on another site?

Answers (2)


Hai Bui answers:

I found an answer for your question in this article

Put this in functions.php (please change the parameters for wp_nav_menu)


if ($_SERVER['REQUEST_URI'] == '/menufeed/main')
// Set the content-type to server javascript code
$expires = 60*30; // seconds * minutes (30 minute cache)
header("Pragma: public");
header("Cache-Control: maxage=".$expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
$menu = wp_nav_menu(array(
'theme_location' => 'main_menu'
'menu_id' => 'main_menu',
'container' => 'none',
'echo' => 0

// Remove newlines and tabs (for more reliable javascript)
// Also escape quotes with addslashes
echo 'document.write("' . addslashes(preg_replace(array('/\n/', '/\t/'), "", $menu)) . '");';


Then on the other site/domain, just add the javascript to print the menu.
<script type="text/javascript" src=""></script>


Francisco Javier Carazo Gil answers:

Hi Overhaul,

Menus in WordPress are saved in the same table as post. What do you want exactly?
* Copy a menu between different sites
* Copy a menu builder of your theme to another one

Tell me.

Overhaul Media comments:

both menus on both domains would be synchronized.

so updating wordpress menu would automatically update our shopify menu.

we were thinking that there may be an rss query we could use and read the rss using js. however we're open to other suggestions.

Francisco Javier Carazo Gil comments:

Hi, I can't see in [[LINK href=""]]Shopify API Documentation[[/LINK]] how menus work but I can tell, how I would do it:
1. Find which hook works when you create a new menu item in WordPress
2. Make a function which is called when this hook triggers
3. The function connect to Shopify using JSON or XML over HTTP
4. Then you send needed data