Hey folks,
I’ve been slaving over this issue the whole night … i got in trouble too … and can’t seem to find any solution for it.
URL: http://sjbci.org/index_test.php [update: this link no longer works!]
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 `ID`,`post_title` FROM $wpdb->posts WHERE `post_status`= “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 `ID`,`post_title` FROM $wpdb->posts
WHERE `post_status`= “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. It’s a performance bottleneck anyway.
Any thoughts?
Recent Comments