Thread Starter
dvalin
(@dvalin)
$result = $wpdb->get_results($SQL);
//$result = mysql_query($SQL) or die("A MySQL error has occurred.<br />Your Query: " . $your_query . "<br /> Error: (" . mysql_errno() . ") " . mysql_error());;
while($row=mysql_fetch_assoc($result)){
thats what I am trying to do but its not working.. the comment out is how I was doing it before.
You don’t even need to query the database directly for this…
WordPress has functions which let you switch which blog is currently being queried, so you could just switch to the differant ones, and then use query_posts as you would normally.
The functions you want are
switch_to_blog($blog_id);
restore_current_blog();
Thread Starter
dvalin
(@dvalin)
never mind solved the problem
Thread Starter
dvalin
(@dvalin)
Ah, I didnt know about those commands…
What I am doing now is this.
$sql2="SELECT wp_".$row['blog_id']."_posts.post_date, wp_".$row['blog_id']."_posts.post_title, wp_".$row['blog_id']."_posts.post_content, wp_".$row['blog_id']."_options.option_value,wp_blogs.blog_id,wp_blogs.domain FROM wp_".$row['blog_id']."_posts, wp_".$row['blog_id']."_options,wp_blogs WHERE option_name = 'template' and wp_blogs.blog_id='".$row['blog_id']."' AND post_type='post' AND post_status='publish' ORDER BY post_date DESC LIMIT 0,1 ";
So with a single query I get out the info I need, that query is then part of a loop that goes through all the blogs we have.