The MU forums have moved to WordPress.org

global wp_list_pages from "main blog" (5 posts)

  1. maxaud
    Member
    Posted 14 years ago #

    Can someone tell me why this doesn't work like I'd expect it to?

    function wp_list_main_blog_pages($arg) {
    	global $wpdb,$blog_id;
    	$wpdb->set_blog_id(1);
    	wp_list_pages($arg);
    	$wpdb->set_blog_id($blog_id);
    }

    It outputs the pages from the main blog but it doesn't set the blog id back to the current blog.

  2. maxaud
    Member
    Posted 14 years ago #

    basically trying to do the same thing as this but with less coding:
    http://dustyreagan.com/global-page-navigation-accross-wordpress-mu-blogs/

  3. andrea_r
    Moderator
    Posted 14 years ago #

    <?php switch_to_blog(1);
    wp_list_pages($arg);
    restore_current_blog(); ?>

    (roughly)

  4. maxaud
    Member
    Posted 14 years ago #

    work's perfect thanks.. now I have to get the main blog id from path for each site.

  5. maxaud
    Member
    Posted 14 years ago #

    this should work assuming the dashboard blog is the main blog:
    get_site_option(dashboard_blog);

About this Topic