admin管理员组文章数量:1414908
I'm trying to add some code based on which multisite is shown. However for both the main site and sub-domains it always shows the ID as 1. I've put
$current_site = get_current_site();
var_dump($current_site);
in both the header.php and index.php and they both output the same for every sub-domain:
object(WP_Network)[275]
private 'id' => int 1
public 'domain' => string '...' (length=16)
public 'path' => string '/' (length=1)
private 'blog_id' => int 1
public 'cookie_domain' => string '...' (length=16)
public 'site_name' => string '...' (length=19)
Has anyone else ran into this issue and know of a way to get the correct current id?
I'm trying to add some code based on which multisite is shown. However for both the main site and sub-domains it always shows the ID as 1. I've put
$current_site = get_current_site();
var_dump($current_site);
in both the header.php and index.php and they both output the same for every sub-domain:
object(WP_Network)[275]
private 'id' => int 1
public 'domain' => string '...' (length=16)
public 'path' => string '/' (length=1)
private 'blog_id' => int 1
public 'cookie_domain' => string '...' (length=16)
public 'site_name' => string '...' (length=19)
Has anyone else ran into this issue and know of a way to get the correct current id?
Share Improve this question edited Sep 9, 2019 at 19:46 Alex asked Sep 9, 2019 at 19:40 AlexAlex 1621 silver badge8 bronze badges1 Answer
Reset to default 3When Multisite was first rolled into core (from a project call "multi-user", which is why you'll sometimes see references to "mu-*"), the terminology was that you'd run a site of blogs. Now we refer to a network of sites, but because the functions had all already been named, get_current_site()
gets the current network.
You'll need to use get_current_blog_id()
to get the current site's ID, or get_bloginfo()
or get_blog_details()
for more detailed data on the current site.
Reference
- Note on
get_current_site
本文标签: Strange multisite issue where all sites return same id with getcurrentsite()
版权声明:本文标题:Strange multisite issue where all sites return same id with get_current_site() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745172053a2646034.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论