开发者

Get the WPMU default blog domain

开发者 https://www.devze.com 2023-01-02 01:56 出处:网络
I have a network of blogs that link to each other. The problem is when I want to get the primary blog\'s domain. I need it for things like the the target of the logo when clicked.

I have a network of blogs that link to each other. The problem is when I want to get the primary blog's domain. I need it for things like the the target of the logo when clicked.

I can't seem to find a function in WPMU the retrieves this. I can see the value I want in the wp_site table. I could easily get it with $w开发者_C百科pdb, but its a bit over kill, and if there is a function that can get the value already, then I want to use it.

I would prefer a solution that does not use a hardcoded ID as this can change if the root blog is deleted and/or replaced.


How about get_blogaddress_by_id(1)? This would get the URL for the blog with ID 1 (which is the primary blog by default).

Check out wp-includes/wpmu-functions.php for similar functions.

Note, this might all change with the codebase merge in 3.0.

UPDATE

If you want the site install blog, use the global object $current_site ($current_site->ID). If you want the 'dashboard blog', use get_site_option('dashboard_blog').


<?php
echo 'You are viewing '.get_current_site()->domain;
?> 

see the doc

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号