get_blog_id_from_url()
that function is part of your answer, i’m sure you can do the rest?
pass in the name of the blog (taken from url)
get_blog_id_from_url(“maindomain.com”,”/”.$sitename.”/”)
note: mutlisite uses extra tables for each new blog
as in wp_siteid_posts
so my SQL looks like this:
SELECT post_content,post_title, guid
FROM wp_”.$blogID.”_posts
order by ID desc
limit 5″;
<?php
function getGlobalPostArgs($blog_id, $limit = null, $cat = null){
global $wpdb;
$global_posts = array();
$limit = (empty($limit))?-1:$limit;
$domain = $wpdb->get_var( "SELECT domain FROM {$wpdb->blogs} WHERE blog_id=1");
$posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE guid like '%".$domain."%'");
if($blog_id != 1){
$local_domain = $wpdb->get_var( "SELECT domain FROM {$wpdb->blogs} WHERE blog_id=$blog_id");
$local_posts = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE guid like '%".$domain."%'");
$posts = array_merge($local_posts, $posts);
}
$args = array(
'post__in' => $posts,
'showposts' => $limit,
'order' => 'DESC',
'orderby' => 'ID',
'cat'=> $cat,
'blog_id' => $blog_id
);
return $args;
}
?>
notice how I can only pass one id into blog_id in the arguments.
I can successfully get the posts from a specific blog ($posts contains an array of post id’s), but this won’t work with wp_query, will it? I would have to write a custom query, like you said. I am thinking therefore, I would have to rewrite everything that depends on wp_query, which is a lot of stuff. Any way around that?
This plugin has helped me tons…
http://ww.wp.xz.cn/extend/plugins/feedwordpress/
I have a main blog that pulls it’s content from 4 individual blogs via rss – they become actual ‘posts’. Work’s like a charm
If your template supports widgets, then drag and drop an RSS into your sidebar or footer bar, then refresh your site.
IF you are using an FTP client ALWAYS make sure you refresh you directory from your host panel.
I have never had a problem with widgets for my site from doing this.
Neither of those solutions would allow me to use the native search functionality.. I am now thinking about not using MU and just using categories to organize everything..
The sitewide tags one pulls all blog posts into one blog, which can then be searched using the default search box.
That’s the reverse of what you originally asked. π