The following query works. Note the quotes in AND blog_id != '1'
global $wpdb;
$query = "
SELECT blog_id
FROM $wpdb->blogs
WHERE site_id = %d
AND public="1"
AND archived = '0'
AND mature="0"
AND spam = '0'
AND deleted = '0'
AND blog_id != '1'
ORDER BY blog_id ASC";
$blogs = $wpdb->get_col( $wpdb->prepare( $query, $wpdb->siteid) );
Result in a multi-site with three sites:
blogs = array (
0 => '2',
1 => '3',
)
Related Posts:
- Multisite posts in categories on network
- find a random blogid across my multisite network that has at least one post published
- WPDB Multiple site’s posts and get featured images
- Creating a Post form outside of the Admin
- Using $wpdb Class to Pull Recent Comments Across a Network
- Bootstrapping WordPress MultiSite Outsite of WordPress – No $wpdb
- Retrieving multisite blog IDs, somehow failing to foreach them properly
- Network Plugin Creating Pages for Different Subdomains
- Optimizing Query used for a Shortcode
- Use WordPress MultiSite (WPMS) with a remote database for each created site
- How can i define the order of blogs in a multisite network manually (like pages)?
- How to display users with posts published between two dates (Sorted by Post-Count) [Multisite]
- Check if current site ID and value exist in WPDB
- Multi-site site nav, wpdb->prepare missing argument
- WP MS: How to query over the network
- WP DB Location for “Next Post to Create” Index Value
- Run “get_the_post_thumbnail” with a different table prefix?
- Switching primary site in WordPress Multisite
- Multisite Network Port Num Issues?
- $wpdb->base_prefix not get parent site prefix in multisite
- what are pmxi tables? [closed]
- How to set an option for all sites in my network?
- How to set up wordpress domain mapping on MAMP Pro
- How to hide admin account in BuddyPress? (for security reasons)
- Issue with Custom Roles in Multisite
- Force plugin to be activated only from multisite network dashboard [duplicate]
- Delete sites in wordpress multisite (not suspend)
- Multisite 404 errors and non-www redirecting to home page
- Get first_name and last_name on user_register hook
- User registration on subsite in multisite configuration
- Multisite, turn off “create new site”
- Hard Code Pages into a Theme for a Network (multisite) Installation
- Allowing logged in users to comment without moderation across a multisite installation
- Redirect all users, except network administrators, from the main site to a subsite
- How to get the via url (or site name) on a wordpress network’s home page?
- How To Modify New Sub Blog Immediately When Super Administrator Creates It?
- Create New Site (multisite); can’t get subdomain to work
- Subdirectory multisite – only root admin available on NGINX
- How to Run Code Before a New Site is Created on MultiSite for Validation
- How to use JSONP to make AJAX request to different site on network
- Efficiently manage a huge number of blogs given server-side restrictions
- WP MU – Accessing ‘Domain-Mapped’ WP-Admin with a subdomain
- Accessing multiple sites via FTP
- Multiple homes for multiple languages [closed]
- multisite custom directory
- Getting this code to work in Multisite
- You do not have permission to edit this user
- Search post in all blogs in WPMU?
- Multi-site: removing /blog from posts
- Multiple install for multilanguage. How to?
- Migrating Multisite – Database error, missing wp_blogs table
- Issue with htaccess redirection in WP Multisite
- Cannot access my first sub-site in a multisite [closed]
- How to detect the context of homepage for a wordpress mu sub-blog
- Multsite redirecting to the main site
- Multisite setup help – plain domain/subsite always redirects to domain with subdir multisite
- How to make a php script(app) accessible to all wordpress subdomains in a wordpress multisite configuration?
- Multisite with 220+ sites painfully slow
- Multisite: cloning, but also updating too
- Add multisite switch button. Click to switch to other page in same admin area
- WooCommerce Multisite — importing products IN subsites FROM main site
- Efficient way to handle translations with Multisite WordPress installation
- MU/Subdomains + Domain Mapping + SSL?
- WordPress Mulitisite – Unable to create directory
- How do I find where the current value of the option ‘registration’ in the SQL database?
- How do I remove the “http://” from network_site_url?
- is_main_site() Always Returns True
- Strange multisite issue where all sites return same id with get_current_site()
- Mass Update Broken Links
- Permalink with a Category and then a Post
- Performance disadvantge of second installation instead multisite feature?
- What is the simplest way to disable multisite leaving one of the sites only?
- How much resources are good enough for 3.9.2
- Best Practise: Linking to WPMU sites from other sites
- Subdomain is not working
- Common user login for two different wordpress installation and bbpress
- How to automatically create an index of child sites at the root url for a multisite installation?
- WordPress Multisite and how to apply sef urls only to specific sites
- Custom css – WordPress Multisite
- Migration: previous URL redirection after migrating
- how to convert a wp multisite into a single site with content from subsites
- Getting stylesheet error after setting subdomain to false in multisite
- String translation within WordPress multisite with i18n not working on all sites
- Add new sites on the same level as the parent URL in a multisite
- URLs for (MultiSite) link images are always relative
- Add radio button on theme at the select of the theme the same theme should be activated after generation of new site in multi site
- Moving wordpress multisite to new domain
- Which action hook to update custom field at network/site-info.php in multisite on update site info
- multisite shared settings
- Multi Site Translate Strings
- Should I use MultiSite for a subdomain based wp site?
- Can’t import posts in multisite
- User registration problem on multisites web
- Admin user getting redirected to /wp-admin/user
- Getting 404 after Update in Multisite
- personal_options hook on WordPress multisite
- There is no featured image in my post in wordpress multisite theme [closed]
- 404 error in dashboard of subdomain of multisite
- How do I test my WordPress subdomains on AWS during migration?
- Access website using hosts due to expired domain [closed]