Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • On another note, I used code from the Diamond Multisite Widget to get a global display of posts. Does anyone know if querying this way, with a bunch of UNIONs, is more efficient?

    global $wpdb;
    				global $blog_id;
    				$table_prefix = $wpdb->base_prefix;
    
    				$sqlstr = '';
    				$blog_list = get_blog_list( 0, 'all' );
    
    				$sqlstr = "SELECT * from ".$table_prefix ."posts where post_status = 'publish' and post_type = 'post' ";
    
    				$uni = '';
    				foreach ($blog_list AS $blog) {
    					if ($blog['blog_id'] != 1) {
    						if ($sqlstr != '')
    							$uni = ' union ';;
    						$sqlstr .= $uni . " SELECT * from ".$table_prefix .$blog['blog_id']."_posts  where post_status = 'publish' and post_type = 'post' ";
    					}
    				}
    
    				$limit = '';//' LIMIT 0, 5';
    				$sqlstr .= " ORDER BY post_date_gmt desc " . $limit;		
    
    				$post_list = $wpdb->get_results($sqlstr);
    				echo $wpdb->print_error();
    				print_r($post_list);

    Also, does anyone know why this query doesn’t include the blog_id column in the recordset that it returns? I can’t figure it out…you would think that SELECT * would give you all the columns.

    Thanks northpen and all contributors for writing on this topic! I have the spent the past few days trying to figure out how to do a multisite query.

    Northpen, I was using the last bit of code you sent and I think I found an error: when the blog_id == 1 (for the main blog) you are using the query:

    SELECT ID FROM wp_1_posts

    when I think it should be

    SELECT ID FROM wp_posts

    I fixed this just with an if statement. I also took out the $display– because I wasn’t sure what it was doing.

    global $wpdb;
    				global $post;
    				$postArray = array();
    				$blog_list = get_blog_list( 0, 'all' );
    
    				foreach ($blog_list AS $blog){
    				  switch_to_blog($blog['blog_id']);
    				  $posts = $wpdb->get_col( "SELECT ID FROM wp_".$blog['blog_id']."_posts WHERE post_status = 'publish' AND post_type = 'post'");
    				  if ($blog['blog_id'] == 1)
    					$posts = $wpdb->get_col( "SELECT ID FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post'");
    				  foreach($posts as $post){
    					$postdetail=get_blog_post($blog['blog_id'],$post);
    					setup_postdata($postdetail);
    					$postIndex = array(
    					  'start_date'  =>  get_post_meta($postdetail->ID, "_EventStartDate", $single = true),
    					  'title'       =>  $postdetail->post_title,
    					  'content'     =>  $postdetail->post_content
    
    					);
    					array_push($postArray, $postIndex);
    				  }
    				}
    
    				asort($postArray);
    
    				foreach($postArray as $key => $value) {
    				  print "$key: $value<br>";
    				  foreach($postArray[$key] as $K => $v){
    					print "$k: $v<br>";
    				  }
    				}

    Just delete these folders in the theme folder you are using:

    • activity
    • blogs
    • forums
    • groups
    • members
    • registration

    then if you want it fully removed deactivate bp and the template pack and delete them.

    Ahhh hahah I see now. I thought ‘blogs.dir’ was supposed to be a text file. I created the directory and now it works fine.

    The second question is still up for grabs though! Thanks in advance.

    Hey guys, thanks for you responses to this issue. I don’t have a ton of understanding of WPMS, and I am having a similar problem.

    I want my subsite users (which are configured as subdomains) to be able to upload, but when I created a test account and tried to upload an image, it says:

    Unable to create directory /hermes/bosweb/web294/b2941/ipg.utv13/wp-content/blogs.dir/2/files/2010/08. Is its parent directory writable by the server?

    I set the permissions to 755 of blogs.dir, just like wp-content. I don’t understand though how something could upload to a subdirectory of blogs.dir, because it isn’t a folder, right?

    Another question of mine:
    Is it possible to make The Loop in my main blog spit out posts from all the blogs in my network?

Viewing 6 replies - 1 through 6 (of 6 total)