Support » Plugins and Hacks » Hacks » Grabbing menu info from another wp site

Grabbing menu info from another wp site

  • Hey everyone.

    I’ve got multiple WP sites, each with their own flavor, but I’m putting together a Plugin to add a global header across them all. In this header i want a menu from 1 of the WP sites.

    So what i’m looking for is a way to use “wp_nav_menu” in a plugin, to get the menu from a Specific WP installation. I’m sure i remember reading a way to do it by temporarily swapping “$wpdb” info. I have tried to find said info again, with little success.

    Does anybody know of a way to either use the “wp_nav_menu” function in this way, or any other way i may be able to get the menu off another WP Installation?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Redefining $wpdb may work, worth a try.

    $localdb = $wpdb;
    //do $args and wp_nav_menu() stuff here
    $wpdb = $localdb;

    The static parameters do not exist, they are only examples, you need to put in the actual values for the “remote” site. I don’t know if that’s all there is to this or not, it’s easy enough to be worth trying.

    Another method might be to create a page on the remote site that does nothing but display the menu, then call it inside an iframe from the other sites.

    Thanks for the advice. I’ve given it a try. I think changing the “$wpdb” only effect getting info directly from the database. When i used it in conjunction with “wp_nav_menu” it seemed to yield no results.

    I even tried using “bloginfo( url )” to see which site, if any, it would grab the info from. Even using the “$wpdb” fix above resulted in the info from the local site being produced.

    Official 🙁

    I did a classic noob mistake… we must have the line global $wpdb; in the function or on the template somewhere.

    I don’t know if adding it will help, but it will not work without it. You may have caught this, but either way, my apologies.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Grabbing menu info from another wp site’ is closed to new replies.
Skip to toolbar