pulling data from multiple blogs/multiple db’s from a single static page
-
Hey folks,
I’ve been slaving over this issue the whole day and can’t seem to find any solution for it.
URL: https://sjbci.org/index_test.php
Notice the sidebar boxes containing Devotions and News & Announcements entries. I did declare different wp-config.php’s, it seems that which db is declared first gets to persist its data and the other $wpdb->get_posts gets to keep the previous data as if it never queried the second db.
here’s the code of the sidebar entries:
<div class="mSide"><strong>Devotions </a></strong><br /> <?php $how_many=5; //How many posts do you want to show require_once("./devotions/wp-config.php"); // Change this for your path to wp-config.php file ?> <? $devotions=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts WHERE <code>post_status</code>= \"publish\" ORDER BY 'ID' DESC LIMIT ".$how_many); foreach($devotions as $devo){ print ("? "); print ("<a href=\""); echo get_permalink($devo->ID); print ("\">$devo->post_title</a>"); print ("<br />"); } ?> </div> <div class="mSide"><strong>News & Announcements</strong><br /> <?php $how_many=5; //How many posts do you want to show require_once("./news/wp-config.php"); // Change this for your path to wp-config.php file ?> <? $ijk = 0; $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts WHERE <code>post_status</code>= \"publish\" ORDER BY 'ID' DESC LIMIT ".$how_many); foreach($news as $np){ $ijk++; print ("$ijk. "); print ("<a href=\""); echo get_permalink($np->ID); print ("\">$np->post_title</a>"); print ("<br />"); } ?> </div>
here are my prefixes,
devotions: $table_prefix = ‘wp_’;
news: $table_prefix = ‘news_’;What’s the best way to accomplish this without using XML. I know I can always cURL the feed then do some domdocument and xpath mumbo-jumbo in PHP but I don’t want to do that.
Any thoughts?
- The topic ‘pulling data from multiple blogs/multiple db’s from a single static page’ is closed to new replies.