Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using multisite for a real estate agent association and I have a plugin that will get all listings within the network and post to main site as a post, plugin is working great; the plugin used to create the listings is not a multisite plugin so that plugin create its own table with the blog id prefix. When the multisite plugin calls for each listing, it only displays the thumb, title and metainfo, which is fine, but I want it to display certain details of the listing also, I create a bit of code to pull the required info, it works to a point where it pulls all the info from the table instead of just getting the result per post. can some one please help the code is below and you can see it in action at the following link. http://apit.gruposanoja.com/inmuebles/

 // Switch to the blog
 switch_to_blog($all_blogkeys[$field->guid]);
 global $wpdb;
 $prefix = $wpdb->prefix;//get current site table prefix
 $table_listings = 'rex_listings'; // name to attach to prefix
 tablename = $prefix.''.$table_listings; // combine prefix and name
 $table_posts = 'posts'; // name to attach to prefix
 $table = $prefix.''.$table_posts; // combine prefix and name
 //start the query and echo results
 $result = $wpdb->get_results("SELECT listing_id, price, bedrooms, baths, floor_space FROM $tablename, $table WHERE $tablename.listing_id = $table.id");
 foreach($result as $row ){
 echo "<div class='info'> Lisitn ID: <span> $row->listing_id</span> <br/> Price: <span>$       $row->price</span> <br/> Bedrooms: <span>$row->bedrooms</span> <br/> Baths: <span>$row->baths</span> <br/> Floor Space: <span>$row->floor_space sqm</span> <br/></div>";
 }
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.