Integrating blogs between to separate WordPress websites

Hi

The UK office and the rest of the world have a WordPress multi-site instance they share.

The Australia and New Zealand Offices want to share there own separate WordPress multi-site but they want to integrate their blog with the UK and rest of the world site.

I would like a point in the right direction for the best way to achieve this any recommendations are welcome and much appreciated.
Jeremy LeysTechnical LeadAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

James RodgersWeb Applications DeveloperCommented:
ok,  just to clarify....

the anz office want to integrate their blog with the rest of the world offices.
Are you meaning show the uk/can/den (for example) blogs on the anz site? or you want the anz office blogs on the uk/can/den sites?
1
James RodgersWeb Applications DeveloperCommented:
quick and dirty

to pull form other blogs to the ANZ site you need to do something along the lines of

// get thecurrent blog id, needed later
$original_blog_id = get_current_blog_id(); 

// get the blog you want to pull from
// https://codex.wordpress.org/Function_Reference/get_blog_id_from_url
$blog_id = get_blog_id_from_url( 'www.domain-3.uk.com' );

switch_to_blog($blog_id); // this function neeeds an int, the blog id you want to interact with

then use
//https://codex.wordpress.org/Template_Tags/get_posts
$latest_posts = get_posts($args);
or
// https://codex.wordpress.org/Function_Reference/wp_get_recent_posts
$latest_posts = wp_get_recent_posts($args );

and process though a loop routine to output

//
// !!!!IMPORTANT!!!!
//
// switch back to your original blog !!!!!!
switch_to_blog($original_blog_id);

Open in new window



to get a listing of posts
you may want to gather all the posts from the different blogs into an array and sort them based on date posted before displaying them
also, if you are doing multiple sites, you just make an array of domains  and loop over it

$domains = array('www.domain-1.com', 'www.domain-2.com','www.domain-3.uk.com','www.domain-4.ca','www.domain-5.com');

foreach($domains as $domain){
	$blog_id = get_blog_id_from_url( $domain );
	// etc...
}

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jeremy LeysTechnical LeadAuthor Commented:
Thank you works like a charm
0
Jeremy LeysTechnical LeadAuthor Commented:
Thank you this solved my problem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Blogs

From novice to tech pro — start learning today.