Adding Site Stats to Nelo Header
Thanks in advance for any help. I searched and could not find any topics discussing what I am attempting here...
I'm trying to add the site stats that appear in the header of the Edu-Clean theme, to the WPMU Nelo header. I have succeeded in getting the stats to show, using the edited code below:
<div class="site-stats"><span>Currently home to <?php
$stats = get_sitestats();
$tmp_user_count = number_format ($stats[ 'users' ] );
$tmp_blog_count = number_format ($stats[ 'blogs' ] );
print "" . $tmp_user_count . " members" . "";
;?> and <?php
$stats = get_sitestats();
$tmp_user_count = number_format ($stats[ 'users' ] );
$tmp_blog_count = number_format ($stats[ 'blogs' ] );
print "" . $tmp_blog_count . " blogs" . "";
;?></span></div>
These stats, however, do not update when a new site is created, or a user is deleted. And, if I wrap all of the above with the following tags, the whole line of stat info does not print at all:
<?php if($multi_site_on == "true"){ ?>
// if code from above added here, nothing prints
<?php } ?>
When I first edited the header to add the code above (without the second php wrapper), the user count was correct, but the blogs count was less than the number shown in ms-sites. When I added a site an as existing user, the blog count did not change. Could this not be counting multiple sites owned by users? When I deleted a user, the user count did not change.
Any suggestions to get this working are greatly appreciated! Here is a link to the code in action.
Everyday at WPMU DEV we help hundreds of WP Users. Become a member today to:
- Download 250+ Premium Plugins and Themes
- Get unlimited support from WordPress Experts
- Get help with your WordPress or BuddyPress projects
Help & Support from WPMU DEV members and staff
Hiya,
I'm not seeing anything wrong with the code. This is a standard WordPress function:
http://codex.wordpress.org/WPMU_Functions/get_sitestats
Try recoding with the format listed on the function link, but it should be working as is.
Thanks!
hi jcnjr
do not use the $multi_site_on conditional...they only work in our buddypress compatible theme
like the edu-clean..etc
try using
<?php if( is_multisite ) { ?>
// if code from above added here, nothing prints
<?php } ?>
you may need to wait for the count cache clear...
Get personal, comprehensive and timely support and assistance
from WordPress Experts
...it should be working as is.
Interesting thing, that. Looks like it is working after all, but as Ricky mentioned, the cache must have needed to clear for the update to show.
I've replaced mu code above with the much simpler version Mason linked to and it's still working. Only thing now is that the blogs count is less than the number shown in wp-admin/ms-sites.php ... might this only be calling sites set as public? The users count is accurate.
The code that sitestats pulls it's data from is cached for I believe an hour. It also doesn;t take into account blogs that have been deleted, archived, or marked as spam.
Not sure where it is in the new code but I know where it is in the old code so I;m going to provide a link to that:
http://trac.mu.wordpress.org/browser/trunk/wp-includes/wpmu-functions.php#L61
Please note line 67 there with the 3600 second bit.
And the blog count:
http://trac.mu.wordpress.org/browser/trunk/wp-includes/wpmu-functions.php#L664
Cached on line 671. Line 672 has what gets counted.
Hope this helps,
-drmike




WPMU Nelo is a CMS frontpage or blog theme thats a little bit special. Not only does it allow a massively configurable layout, but also simple editing of all images without a custom field in sight!