The MU forums have moved to WordPress.org

Why does get_posts() go to wrong database? (3 posts)

  1. deko
    Member
    Posted 17 years ago #

    I have two WordPress installations on my site arranged in separate directories, like this:

    /public_html/wp-blog1/
    /public_html/wp-blog2/

    Seems to be working okay, except for when I use the get_posts() template tag.

    If I try to do this in wp-blog2:

    $arg = "numberposts=50"
    $posts = get_posts($arg);
    foreach($posts as $post) : setup_postdata($post);

    ...
    <?php endforeach; ?>

    I get a listing of posts in wp-blog1 (!)

    Is there any way to specify which database get_posts() gets from?

    Why am I having this problem?

    How do I use get_posts() with two WP installations?

    Thanks

  2. andrea_r
    Moderator
    Posted 17 years ago #

    Are you using WP or WPMU? Do the two installations share a database?

  3. deko
    Member
    Posted 17 years ago #

    I guess I'm using WPMB - multiple blogs. There's normally only one user. The reason I'm using multiple databases is for scalability. I want to keep the size of my databases as small as possible. When a database reaches a a few hundred meg, I tear off a category and put it in it's own db.

    So I guess I've posted in the wrong forum.

    In any case, I think I figured out what was going on (long story).

About this Topic