Switch Blog in WPmu


Some time we need to make some common header,sitebar and footer in wpmu site sub-domain . We can do this easily by make a common template in root site and use those header,sitebar and footer on that sub-domain site .

To use root’s header in sub-domain by wordpress default function , we just set the switch_to_blog() function after that reset the blog by restore_current_blog();

Example :

suppose we use the wp_get_pages() in theme header .
when any sub-domain site use that theme then it can’t get the wp_get_pages() function result . we need to create again those pages . But if we use switch_to_blog(1) then the header will work . Then after reset the blog by restore_current_blog(); function .

switch_to_blog(1)
wp_get_pages()
restore_current_blog();

,

Leave a Reply