get_current_blog_id returns 1 in multisite setting

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.

Leave a Comment