How to get current site id? (WPMU)

I am using WordPress with MU activated. I found a function here that supposed to return an object with the current side ID. But it’s returning 1 for all websites.

<?php get_current_site(); ?>

2 s
2

You’re right, get_current_site()->blog_id will return 1, as it refers to the network.

To get the current site (blog) ID you can go like this:

<?php echo get_current_blog_id(); ?>

Moreover you can get the current site (blog) details like this:

<?php var_dump(get_blog_details()->blog_id); ?>

Leave a Comment