php WPMU DEV在多站点网络中列出站点

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WPMU DEV在多站点网络中列出站点相关的知识,希望对你有一定的参考价值。

/*
Theme Name:     Child Theme for Multisite Network
Theme URI:      https://github.com/rachelmccollin/wpmu-dev-list-network-sites
Description:    Theme to support WPMU DEV post on adding alist of all sites to each site in the network. Child theme for the WPMUDEV Parent Theme theme.
Author:         Rachel McCollin
Author URI:     http://rachelmccollin.co.uk/
Template:       wpmudev-parent-theme
Version:        1.0
*/

@import url("../wpmudev-parent-theme/style.css");
$subsite_id = get_object_vars( $subsite )["blog_id"];
$subsite_name = get_blog_details( $subsite_id )->blogname;
$subsite_link = get_blog_details( $subsite_id )->siteurl;
echo '<li class="site-' . $subsite_id . '"><a href="' . $subsite_link . '">' . $subsite_name . '</a></li>';
.subsites-container {
	background: #3394bf;	
}
ul.subsites {
	list-style-type: none;
	overflow: auto;
	max-width: 1000px;
	margin: 0 auto;
}
ul.subsites a {
	float: left;
	margin: 0.5em 1em 0.5em 0;
	color: #fff;
}
/* list of network sites */
ul.subsites {
	list-style-type: none;
	background: #3394bf;
	overflow: auto;
}
ul.subsites a {
	float: left;
	margin: 0.5em;
	color: #fff;
}
ul.subsites a:hover,
ul.subsites a:active {
	text-decoration: none;
	color: #183c5b;
}
ul.subsites {
	list-style-type: none;
	overflow: auto;
	max-width: 1000px;
	margin: 0 auto;
}
function wpmu_list_sites() {
	
	$subsites = get_sites();
	
	if ( ! empty ( $subsites ) ) {
		
		echo '<ul class="subsites">';

		foreach( $subsites as $subsite ) {
		
	
		}
		
		echo '</ul>';
	
	}
	
}
add_action( 'wpmu_before_header', 'wpmu_list_sites' );
function wpmu_list_sites() {
	
	$subsites = get_sites();
	
	if ( ! empty ( $subsites ) ) {
		
		echo '<ul class="subsites">';

		foreach( $subsites as $subsite ) {
		
			$subsite_id = get_object_vars( $subsite )["blog_id"];
			$subsite_name = get_blog_details( $subsite_id )->blogname;
			$subsite_link = get_blog_details( $subsite_id )->siteurl;
			echo '<li class="site-' . $subsite_id . '"><a href="' . $subsite_link . '">' . $subsite_name . '</a></li>';
	
		}
		
		echo '</ul>';
	
	}
	
}
add_action( 'wpmu_before_header', 'wpmu_list_sites' );
function wpmu_list_sites() {
	
	$subsites = get_sites();
	
	if ( ! empty ( $subsites ) ) {
		
		echo '<section class="subsites-container">';
		
			echo '<ul class="subsites">';
	
			foreach( $subsites as $subsite ) {
			
				$subsite_id = get_object_vars( $subsite )["blog_id"];
				$subsite_name = get_blog_details( $subsite_id )->blogname;
				$subsite_link = get_blog_details( $subsite_id )->siteurl;
				echo '<li class="site-' . $subsite_id . '"><a href="' . $subsite_link . '">' . $subsite_name . '</a></li>';
		
			}
			
			echo '</ul>';
			
		echo '</section>';
	
	}
	
}
add_action( 'wpmu_before_header', 'wpmu_list_sites' );

以上是关于php WPMU DEV在多站点网络中列出站点的主要内容,如果未能解决你的问题,请参考以下文章

如何在多站点网络中显示主站点的主菜单

php 使用多站点重复帖子在多站点上复制事件后更新时间信息

php WPMU DEV自动导航菜单

Docker wordpress 多站点 - 要公开哪些端口?

在多站点上为 Sonata Admin 同步缩略图

php 在WPMU DEV Google Maps Add-on中将地理标记限制从硬集6更改为无限制