I am encountering rather a weirdo situation here.
I am currently on a multisite and created a site. This site has a blog id of 3. However, whenever I call get_current_blog_id() it returns 1 (which is obviously a network id).
I do not know why but there was definitely a change with the domain.
example)
used to be
random.com/the_mania
now it is
random.com/community/the_mania
I am running IIS by the way. What would be the cause for this?
1 Answer
get_current_blog_id()
uses the global variable $blog_id
as noted at https://codex.wordpress.org/Function_Reference/get_current_blog_id. When I’ve seen this problem before it’s because I’m declaring $blog_id
in my PHP code which is overwriting the WordPress global variable that provides the ID of the subsite.
Change the variable name of $blog_id
and hopefully the function will start returning the correct site ID.