Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#27701 closed enhancement (duplicate)

WordPress Multi-site Global Query

Reported by: kegster's profile kegster Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description

I have a unique situation where my entire network is a big CMS with one site being the "admin" site, of which the users have access to view all the information from all the sites on the network.

Instead of looping through each blog/site for the same query, I would love to question if there's any possibility to do a global query?

The only solution I have deduced is that I need to create / maintain a custom table or tables that basically stores at minimum the post ID, blog ID, and post_type. I am trying not to isolate this enhancement to my own project. I am aware this method does nothing to support WP_Query in any way.

So on that note, how about something to modify WP_Query to accept a 'blog_id' parameter that allows for 'any' as an option as well (similar to how WP_Query handles 'post_type' => 'any'.

I'm sure this had been thought of before, but unsure how that'd look. Blog looping seems quite inefficient.

Change History (2)

#1 @knutsp
11 years ago

Interesting suggestion.

When wanting one "big" CMS WP Multisite is usually not the optimal solution. There are two main reasons for setting up a "integrated" Multisite as a "trusted" network. One is the ability to have different domains or paths, the other is to have different themes. The recommended way of separating content into thematically different realms is to use categories strictly and have no "blog page".

One may have WordPress display a different theme for each (main) category or some other taxonomy. One could think of a solution having different domains on the same site, filtering the category or a "site taxonomy" by domain.

By setting up a multisite you separate all content into different DB tables. A special installation of multisite using a common posts/postmeta should perhaps be possible, and this table could have a "site" column. It would be fairly complicated to support both ways, I'm afraid.

The last way is to have a special WP_Multi_Query, or integrated into WP_Query, as you suggest, to query several tables. How would the SQL for such query look like? Just adding a site argument, and make WP_Query use switch_to_blog() would not be effective.

Is it possible to set up a view in MySQL to join different tables and have new "virtual" primary key based on site+ID?

I don't see this kind of thing in the suggested multisite roadmap.

I believe the only way forward here is to demonstrate fast querying for multisite posts, introducing a new API, in a plugin. Then this plugin would be the solution, most probably.

#2 @SergeyBiryukov
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #22816.

Note: See TracTickets for help on using tickets.