• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    PHP
  • Created almost 13 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

If you're using this reconsider your site architecture or use ElasticSearch

WP_Query_Multisite is a subclass of WP_Query, WordPress' post querying class. The class does everything behind the scenes, so the only change you make to query multisite is the in the class declaration expression.

Example usage:

$query = new WP_Query_Multisite( array( 'post_type' => 'post' ) );

while( $query->have_posts() ) : $query->the_post();
    echo $blog_id . get_the_title() . "<br>";
endwhile;

wp_reset_postdata();

To modify what sites are queried, create a sites key in the $args in the constructor parameter, with a sub-element of either sites__in or sites__not_in, which will be an array similar to posts__in in the WP_Query object.

Example usage:

$args = array(
	'post_type' => 'post',
	'sites' => array(
		'sites__in' => array( 1, 2, 3, 5 )
	)
);

$query = new WP_Query_Multisite( $args );

while( $query->have_posts() ) : $query->the_post();
    echo $blog_id . get_the_title() . "<br>";
endwhile; 

wp_reset_postdata();

Alternative

We do want to suggest that this version / fork uses pre_get_post and may be a better solution for you. This way you can keep using the good 'ol WP_Query without editing any theme files.
https://github.com/miguelpeixe/WP_Query_Multisite

More Repositories

1

emoji-mosaic

JavaScript
710
star
2

wp-media-javascript-guide

Interactive documentation for the Javascript powering WP Media.
CSS
313
star
3

web-development-contract

Web Development Contract
71
star
4

learn-prosemirror

JavaScript
25
star
5

underscore-visual-cheat-sheet

Visualize your functional JavaScript programming.
25
star
6

https-http2-and-wordpress

Learn about HTTPS and HTTP2, and how to set them up. Geared towards WP developers.
24
star
7

web-dev-resources

A table of contents for web developer resources across the internet.
24
star
8

bitmap-js

Read and create bitmap image files in Node
JavaScript
20
star
9

create-react-app-minimal

create-react-app with my preferred src boilerplate
JavaScript
18
star
10

say-yes-to-https

A practical guide to encryption for web developers
CSS
15
star
11

wp-custom-css-per-post

A plugin that allows you to have custom CSS per post, editable via the Customizer
PHP
15
star
12

mta-realtime-subway-departures

JavaScript
12
star
13

WP_Settings_Page

An object-oriented approach to make creating WordPress settings pages easier.
PHP
12
star
14

netflix-library-indexer

JavaScript
12
star
15

super-var-dump

A customized var_dump walker for viewing complex PHP variable data with ease.
PHP
9
star
16

super-emoji-plus

Add emoji in your WP Editor
CSS
9
star
17

ericandrewlewis.github.io

HTML
7
star
18

prosemirror-wordpress-example

An example plugin that shows how to use a ProseMirror editor in WordPress.
JavaScript
5
star
19

wp-publish-meta-box-2-point-oh

Streamline the publish meta box workflow.
JavaScript
5
star
20

how-a-quadtree-works

HTML
4
star
21

kubernetes-via-terraform

HCL
4
star
22

react-workshop

JavaScript
4
star
23

b2

PHP
3
star
24

prosemirror-with-react-rendered-node

JavaScript
3
star
25

ericandrewlewis.com

HTML
2
star
26

c-plus-plus-pointers-cheat-sheet

Because pointers are hard as fuck
C++
2
star
27

git-or-svn

JavaScript
2
star
28

meadow

A WordPress Fields API
PHP
2
star
29

wp-meta-data-models

PHP
2
star
30

pad

JavaScript
2
star
31

mta-subway-stations

JavaScript
2
star
32

prosemirror-basics

JavaScript
1
star
33

prosemirror-dev-tools

HTML
1
star
34

wp-post-forking-two-electric-boogaloo

PHP
1
star
35

polygon-test

C++
1
star
36

twitter-upside-down

JavaScript
1
star
37

cool-text-converter

ḁdd some̊ spice̊ to ẙoůr̥ life̊
HTML
1
star
38

WP-Plugin-OLD-Site-Setup-Wizard

Wordpress Plugin - Site Setup Wizard
PHP
1
star
39

find-with-react-blessed

JavaScript
1
star
40

saml-20-single-sign-on

PHP
1
star
41

facebook-indifference

Taking the like out of Facebook
CSS
1
star
42

mta-train-times-on-an-lcd-screen

JavaScript
1
star
43

wp-cool-slugs

PHP
1
star
44

Eric-Andrew-Lewis-8-bit-Side-Scroller-Website

JavaScript
1
star
45

how-a-php-program-works

PHP
1
star
46

tech-wont-build-it-twitter-visualization

JavaScript
1
star
47

codecademy-board-slides-for-foodwheel-project

Jupyter Notebook
1
star
48

css-colors-ordered-by-hue

HTML
1
star
49

react-reverse-order-with-lazy-load

Reverse order of posts in React with lazyload
JavaScript
1
star