-
-
Save rachelmccollin/d5ebccb8fb08b4de4008fcc015e6c51c to your computer and use it in GitHub Desktop.
WPMU DEV Listing Sites in a Multisite Network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.subsites-container { | |
background: #3394bf; | |
} | |
ul.subsites { | |
list-style-type: none; | |
overflow: auto; | |
max-width: 1000px; | |
margin: 0 auto; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ul.subsites a { | |
float: left; | |
margin: 0.5em 1em 0.5em 0; | |
color: #fff; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ul.subsites { | |
list-style-type: none; | |
overflow: auto; | |
max-width: 1000px; | |
margin: 0 auto; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment