Make WordPress Core

Opened 8 years ago

Closed 6 years ago

Last modified 6 years ago

#38025 closed enhancement (maybelater)

Query networks with meta_query

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by: spacedmonkey's profile spacedmonkey
Milestone: Priority: normal
Severity: normal Version: 4.6
Component: Networks and Sites Keywords: needs-patch 2nd-opinion
Focuses: multisite Cc:


It would be great to add a meta_query parameter to WP_Network_Query.

I have a need to do this in my WP Multi Network plugin, to query for networks by the site_admin meta key. I'd also like to be able to orderby the blog_count meta key & value.

Related: #32504

Change History (11)

#1 @flixos90
8 years ago

Theoretically a definitive +1 for me, but we first need to decide how we are going to see network options in the future. There have been several discussions in Multisite weekly chat (latest discussion:, I hope we can come to a decision soon. At the moment for example, calling this parameter meta_query would be weird because this kind of data is commonly known as network options.

Btw the original patch for WP_Network_Query had this functionality, but it was stripped out for the above reasons. See (for the patch, see

Also in order for this idea to work properly, we would need to use the Meta API for network options (at least internally, see #37181) so that cache invalidation works.

#2 @spacedmonkey
8 years ago

I little back story on this one for anyone new to the ticket. @flixos90 's orignal patch did have the meta query in it, but pretty late in the ticket, I asked for it to be removed. There were issues with cache invalidation when you changed the network option. It meant for example, you changed site 2 network option "name" from test to example, the query with a meta query, will still return site 2 for a meta query for "test". It was removed in hopes to put it back in later.

My personal view is the network options (that are formatted as site network meta in the db) should be treated like other object types meta. I have a ticket #37181 open to change in the internals of the *_network_options functions to use the metadata api. I know this is a big change, but opens a lot of doors in the future. Until we decide what is happening with how network options are thought of in core, this ticket will not progress.

I believe that @flixos90 & @johnjamesjacoby and myself have made our feelings clear about making network option more like meta. But I know that @jeremyfelt had his issues with the idea. Would like if we worked on this ticket in 4.8

Related: #37181

This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.

7 years ago

#4 @flixos90
7 years ago

  • Keywords ms-roadmap added

These tickets belong to our planned roadmap (a few of them not per final decision), so flagging with a keyword for better overview.

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.

7 years ago

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.

7 years ago

#7 @spacedmonkey
7 years ago

  • Keywords changed from needs-patch, 2nd-opinion, ms-roadmap to needs-patch 2nd-opinion ms-roadmap
  • Milestone changed from Awaiting Review to 5.0

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.

7 years ago

#9 @flixos90
7 years ago

  • Owner set to spacedmonkey
  • Status changed from new to assigned

Once #37181 is in core, this can be worked on. @spacedmonkey will take care of the patch. Reminder that a lot of it can be taken from the original WP_Network_Query patch (

#10 @flixos90
6 years ago

  • Keywords ms-roadmap removed
  • Milestone 5.0 deleted
  • Resolution set to maybelater
  • Status changed from assigned to closed

As discussed at WordCamp US, we will not introduce actual network meta functionality to core, but only use the API internally in the *_network_option() functions (see #37181). The rest remains plugin territory for now.

#11 @spacedmonkey
6 years ago

I have created a feature project (plugin) for this functionality.

This functionality can live as a plugin...

Note: See TracTickets for help on using tickets.