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?
$localdb = $wpdb;
$wpdb = new wpdb( REMOTE_DB_USER, REMOTE_DB_PASSWORD, REMOTE_DB_NAME, REMOTE_DB_HOST );
//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.