我正在使用 Wordpress 多站点在一个 WP 安装中容纳多个站点
我希望有一个导航显示每个站点以及该站点的链接。
我正在使用此功能来执行此操作
<?php
$bcount = get_blog_count();
global $wpdb;
$blogs = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE spam = '0' AND deleted = '0' and archived = '0' and public='1'"));
if(!empty($blogs)){
?>
<ul class="nav navbar-nav">
<li class="portalHome"><a href="dashboard.html">
<i class="fa fa-home"></i>
<i class="fa fa-chevron-right pull-right chervonMobNav"></i></a></li>
<?php
foreach($blogs as $blog){
$details = get_blog_details($blog->blog_id);
if($details != false){
$addr = $details->siteurl;
$name = $details->blogname;
if(!(($blog->blog_id == 1)&&($show_main != 1))){
?>
<li class="menu-item<?php if($counter == get_current_blog_id()){ echo ' current-menu-item';}?>">
<a href="<?php echo $addr; ?>"><?php echo $name;?> <i class="fa fa-chevron-right pull-right chervonMobNav"></i></a>
</li>
<?php
}
}
}
?></ul><?php
}
?>
它有效,但我也遇到了错误
Warning: Missing argument 2 for wpdb::prepare()
wpdb::prepare() 的第二个参数应该是什么