• Resolved hand_coding

    (@hand_coding)


    Hi,
    I’ve set up a WordPress site with 14 blogs.
    The table prefix for the main blog is just “wp_” while for the other blogs it’s “wp_” + the blog_id, starting at “2”, so I have tables named “wp_posts”, “wp_2_posts”, “wp_3_posts” etc.

    This causes a problem with a plugin whose task is to collect the latest post from every blog. The call to mysql is a foreach loop and looks like “wp_”.$blogid.”_posts” which obviously returns nothing for the main site.

    Is there a way to set the table prefix for the main site to “wp_1_” in place of just “wp_”?

    Thanks…

Viewing 7 replies - 1 through 7 (of 7 total)
  • This is an issue with the way the plugin is written. It needs to be updated to use the proper functions.

    If you want to update the plugin yourself, you should replace all instances of "wp_".$blogid."_posts" with $wpdb->posts. That way, even if you use a prefix other than “wp_” when you install WordPress, the plugin will still work properly. You should then use the $wpdb->set_blog_id() function to switch from one blog to another.

    Thread Starter hand_coding

    (@hand_coding)

    Hi Curtiss,
    I’m not sure I fully understand the ins and outs of your suggestion but I’ll try…

    Thanks a lot…

    Thread Starter hand_coding

    (@hand_coding)

    Well… I was unable to find a way to implement your suggestion in a query like "SELECT post_content FROM " . "wp_" . $blogid . "_posts" … so I ended up with adding a variable based on the blog id: $wp_bid = $blogid == 1 ? "wp" : "wp_".$blogid; so the query is now:"SELECT post_content FROM " . $wp_bid . "_posts" ….

    It works nicely.
    Thanks again…

    This causes a problem with a plugin whose task is to collect the latest post from every blog.

    Find another plugin for this. there are plenty.

    Any plugin specifically written for multisite already knows about the table prefixes. If this plugin does that, then it’s just bad coding, or wasn’t written for multisite.

    Thread Starter hand_coding

    (@hand_coding)

    I don’t think it’s bad coded; it’s just not flexible…
    “list-all-posts” was designed for WordPress-mu and was, at the time, a free gift from WPMU Dev along with “list-all”, designed to retrieve every blogs in a WP-mu install.
    Those are nowhere to be found now, it seems…

    Lucky you are if you found “plenty” of WP plugins for this, because I did a lot of search… ??

    becasue those were developed over 2-3 years ago and not touched since.

    Lucky you are if you found “plenty” of WP plugins for this, because I did a lot of search…

    Guess you completely missed my site then.

    https://wpmututorials.com/how-to/return-a-list-of-sites-on-the-network/

    Thread Starter hand_coding

    (@hand_coding)

    ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Table prefix question with multisite setup’ is closed to new replies.