2

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?

  • Try seeing what get_blog_details() gives you… – William Turrell Apr 23 '15 at 10:00
  • Can you [update your question ](wordpress.stackexchange.com/posts/185111/edit) to include some of the context around your get_current_blog_id() call, please? – Pat J Apr 27 '15 at 12:18
  • @WilliamTurrell I'm getting this value too. When I call get_blog_details() it returns information about the root network site. Site ID is "1" and site URL is the default network blog URL. The site I'm working with is site 93. I log in through the network site URL if that makes any difference. – 1.21 gigawatts Nov 15 '15 at 8:24
3

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.