Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

    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 %s p LEFT OUTER JOIN %sterm_relationships r ON r.object_id = p.ID
    LEFT OUTER JOIN %sterm_taxonomy x ON x.term_taxonomy_id = r.term_taxonomy_id
    LEFT OUTER JOIN %sterms t 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

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