Querying post from a multisite network

You could use your list of blog ids in this way … $posts = array(); foreach ( $your_list_of_blog_ids as $blog_id ) { switch_to_blog( $blog_id ); $query = new WP_Query( array( ‘post_type’ => ‘any’, ‘posts_per_page’ => 10, ) ); while ( $query->have_posts() ) { $query->next_post(); $posts[] = $query->post; } restore_current_blog(); } Important are switch_to_blog and restore_current_blog. … Read more

Changing subdir multisite install to subdir core directory structure

Your .htaccess lines need to look like this: RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) /wordpress/wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ – [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /wordpress/$2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ /wordpress/$2 [L] RewriteRule . … Read more

Templates for Custom Post Types and Custom Taxonomies

You have totally missed the naming convention when coming to the taxonomy archive pages, and most probably the same goes for your archive pages for your custom post types Here is how your taxonomy archive pages should look like taxonomy-{taxonomy}-{term}.php – If the taxonomy were sometax, and taxonomy’s term were someterm WordPress would look for … Read more

How does WordPress Multisite know that a Plugin is installed?

You can clearly see the way WordPress loads plugins if you inspect the source code of the file wp-settings.php. The function wp_get_active_and_valid_plugins() loads plugins for individual sites in the network and for non-Multi-Site installations, while wp_get_active_network_plugins() loads network activated plugins when Multi-Site is enabled. The former more or less just calls get_option() to get the … Read more

WP MultiSite API – Create new sites

There is nothing in the core or in the rest API for this requirement. You can try this plugin, https://github.com/remkade/multisite-json-api Sorry, but I see no other chance and no more to say in this answer. The core function to create a new site in the network of the installation is wpmu_create_blog. But there is no … Read more

Ban SiteNames Multisite

You can filter domain_exists, a check that runs before a site is registered. If you return a positive integer, WordPress will not create that site. Despite its name, that filter lets you check the path too. Sample code, not tested: add_filter( ‘domain_exists’, function( $result, $domain, $path ) { // Already taken, no need for further … Read more