Chase Miller
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Change database conenction at tun time.Personally, I’d just edit wp-load.php.
It tells WP to load wp-config.php. You could add in any of the swapping logic and switch to whichever config file you need.
If that doesn’t work for you, I am available to write you a plugin to swap data between databases.
Forum: Developing with WordPress
In reply to: How to perform this custom query?Sorry for the late reply, but if you are still looking for a solution, you can try something like this:
function cm_getLatest($iCategory = null, $bRestrictByAuthor = true) {
global $wpdb;
if (!is_numeric($iCategory)) { return array(); }
$bRestrictByAuthor = (!$bRestrictByAuthor) ? ” : ‘ GROUP BY p.post_author’;
$sQuery = sprintf(“SELECT * FROM%sp LEFT OUTER JOIN%sterm_relationshipsr ON r.object_id = p.ID
LEFT OUTER JOIN%sterm_taxonomyx ON x.term_taxonomy_id = r.term_taxonomy_id
LEFT OUTER JOIN%stermst ON t.term_id = x.term_id
WHERE p.post_status = ‘publish’ AND t.term_id = ‘%s’%s ORDER BY p.post_date ASC”, $wpdb->posts, $wpdb->prefix, $wpdb->prefix, $wpdb->prefix, $iCategory, $bRestrictByAuthor);
$aResults = $wpdb->get_results($sQuery);
return $aResults;
}Usage would be:
cm_getLatest(CatID, boolean – Limit to 1 post per author)To list all posts with unique authors in category 4, you could use:
print ‘
print var_export(cm_getLatest(4, true), true);LAMP geek always looking for work,
Chase C. Miller