You should use get_current_blog_id()
if you need just the id and get_blog_details()
if you need more fields.
Be aware that get_current_site
in fact gives you information about the network of sites in a WP_Network
object. Yeah, the name is kind of confusing, as noted in the Codex but not yet on developer docs:
Note: get_current_site() was inherited from MU, and is named based on the old terminology which spoke of multiple “blogs” on a “site”. We now speak of multiple “sites” on a “network” instead, but some of the old terminology still lives on in some function names. This function returns information about the current network. To get information about the current site on the network, see get_current_blog_id() and get_blog_details().
It would be something like this.
// get current blog id
$blog_id = get_current_blog_id();
if ( 2 === $blog_id){
// if site id is 2
//middle part for this case
} else {
//if is not
//middle part for this case
}
Related Posts:
- Multisite on Windows with wildcard subdomains
- multisite 404 error for subdirectory
- How to hide or remove unwanted widgets on Multisite installation?
- How to use alias domain for multisite installation?
- Multisite htaccess on localhost with WP as an SVN external?
- WordPress Multisite with multiple domains using Nginx
- Turn off ms-files.php after network setup
- NGinx + WordPress Subdomain Multi with core in Subdirectory
- Redirect to a Plugin Settings Page After Multisite Site Creation?
- WordPress Multisite – Multiple subfolders for blogs
- Uploading/Deploying a Multi Site Install
- How does wordpress multisite manage subdomains?
- How do I fix problems with users not being able to publish and only submit for review after upgrade of Multisites installation?
- subdomain archiving
- Is it possible to fix/repair all Index, Primary Key, Unique (and all other) structure of a WordPress MS Database
- Copy site from one multisite to another
- Trying to migrate a WordPress Multisite with Domain Mapping
- Manipulate list of themes in wp-admin
- add_rewrite_rule not registering on Multisite
- How to update_site_option for specific site within network?
- why when I try to insert an image attachment along with a post does wp_get_attachment_url give me a very wrong file path?
- How to run nested xargs commands?
- how do I configure nginx for wordpress multisite, it occurs ERR_TOO_MANY_REDIRECTS
- How to add edit users capability to a custom role?
- How to change the database prefix in multisite (WPMU) install
- Getting blank thumbnails in media library?
- Subfolder Multisite : optional www subdomain
- 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]
- Icon font not working on subdomains of multisite
- 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
- What is the function to get options of the parent site of a multisite network?
- Issue with htaccess redirection in WP Multisite
- Multisite – sort merged get_posts() queries
- WordPress MultiSite login to the respective site
- 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
- WordPress MU Domain Mapping Just Redirects to Main Site
- 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
- Using the standard WordPress “New User” interface on a multisite
- 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
- InfiiniteWP and WP Networks (multisite)
- Restrict Capability of Administrator to Create, Edit and Delete Pages in Multisite
- Why doesn’t wpmu_new_user work from a plugin when it does from theme?
- MU/Subdomains + Domain Mapping + SSL?
- WordPress Mulitisite – Unable to create directory
- network site domain mapping still applied after being removed
- Can WordPress Multisite (MU) subdirectory url/slug/permalink be changed?
- Multisite Subdomain Redirect Mask
- Add access control origin header information across multisite
- How to exclude specified from all list of Multisite
- Create WordPress Multisite Instance Programmatically
- Multisite Login problem
- How can I use different domains on a WP multisite install?
- WordPress Multisite Network to replace 3 seperate WordPress installations
- WordPress MultiSite Won’t Work on Google AppEngine
- Redirecting to page not found mulitiste
- How to create a blogs category page with Blog-Types Plugin
- Add Network Sites are not working
- How many .htaccess files should a WordPress multisite (subdirectory set up) have?
- Multisite install with subdomains on a subdomain
- Multisite loads assets from main site
- Possible to reverse proxy WP multisite to a separate server with NGINX?
- How to hold posts and accounts for moderation on WordPress Network site
- Problems with WordPress multisite directories/url structures and admin access after migration
- Enable HTTPS for AWS hosted multisite domain (with AWS purchased SSL) on already created Load Balancer?
- WordPress Multisite with Wildcard Certificates not mapping correctly
- Fix nested WordPress multisite resource path?
- How To Upload Existing WordPress Site To WordPress Multisite Using SSH
- How can I make my existing VIP theme to multisite
- how to make a cronjob run, when user needs to be logged in
- After cloning my WordPress database to another server, I cannot log in
- All Subsites of a WordPress Multisite install 302 redirects to the main site
- How to find the site ID on a single site and then add new post with “`multipart/form-data” enctype?
- WordPress Domain Mapping shows new domain in place but takes me to the sub domain
- How can I have different langauges in wp-admin on a multisite installation?
- Problem in viewing recent posts from network site to main site
- Send data using GET method not work correctly
- How to create Network of websites with separate database in WordPress
- In a MS install, can you allow different users to have their own themes?
- WordPress multidomains and subfolders
- Redirect authors from upload.php url to Home page in Multisite
- Multisite: should /blog go to a 404 page?
- WordPress shows death white screen on multisite
- Create service similar to wordpress.com [closed]
- External rewrite rules missing in htaccess – Multisite
- Run WordPress multisite from secondary volume on AWS EC2
- Redirect to Multisite site 2 if site 1 has a setting