1

I have a WordPress site and am adding a Shopify-hosted e-commerce section which will be hosted on their servers and accessible via a subdomain. Is there any way to mirror the WordPress Navigation for my site on another platform and (maybe the harder of the two) subdomain?

I don't intend to use Shopify's product menu at all. So I'm not looking to merge the two or anything... just an easy way to get the WP menu to display elsewhere.

0

Here is a guide. The gist of it is that you create a template file that houses your menu and then call that file from the external website.

  • Good answer, but I'm pretty sure this doesn't apply to a SaaS situation like Shopify, which runs Ruby and won't let me embed PHP. Maybe through their API somehow. Have to look into it. THANKS! – binaryorganic Jun 30 '12 at 21:49
0

Just made a simple test that may be useful.

In my local development Multisite I put two files at the root:

test.html

Loads a WordPress menu in a static page

<html>
<head>
<TITLE>Testing Ajax/WordPress</TITLE>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
    jQuery(document).ready(function($) {
        $("#nav-container").load("http://brasofilo.dev/test.php", function(response, status, xhr) {
          if (status == "error") {
            var msg = "Sorry but there was an error: ";
            $("#nav-error").show();
            $("#nav-error").html(msg + xhr.status + " " + xhr.statusText);
          }
        });
    });
</script>
</head>
<body>
    <div id="nav-container">Container DIV</div>
    <div id="nav-error" style="display:none">ERROR</div>
</body>
</html>

test.php

Returns a WordPress menu

<?php
define( 'WP_USE_THEMES', false );
require( './wp-load.php' );
wp_nav_menu( array( 'menu' => 'Test Menu' ) );

The file test.html was loaded from a subdomain http://test.brasofilo.dev, but the Ajax call failed to load the PHP file at the main domain http://brasofilo.dev due to Same origin policy.

To overcome this, put the following Cross-Origin Resource Sharing rule in .htaccess:

Header set Access-Control-Allow-Origin http://test.brasofilo.dev

  • Oh, sure, I have no idea what Ruby is, and if it can run Javascript... :/ – brasofilo Jul 23 '12 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.