conpeo
Member
Posted 17 years ago #
i refer alot of List-all, List-all-Post, List-all-Blogs, Recent-Posts, Updated-Posts.
but i just look for simple php to display Active Blog and Number of Posts. thanks.
this link refer,
http://mu.wordpress.org/forums/topic.php?id=1063
but alot of php code & html code, i confuse the coma like ' "" ' echo print. i try put this info to front page without plugin.
P/S: or can teach me how to call out display blogname? thanks.
conpeo
Member
Posted 17 years ago #
Oh yeah i have create new simple php, can show All Active Blogs with Blogs' name and Number of total Posts. (i like it because it no need add-on plugin)
I refer alot of List All Blogs function to combine it.
u can copy it to any front page with html code.
welcome to share me if u have better code. thanks.
<div id="blog-list">
<?php
$blogs = get_blog_list(0, 'all');
foreach ($blogs as $blog) :
$url = "http://" . $blog[ 'domain' ] . $blog[ 'path' ];
// This is the table to get the blogname
$tblog = "wp_".$blog['blog_id']."_options";
$blogname = $wpdb->get_col("SELECT option_value FROM $tblog WHERE option_name='blogname'");
// print one line each blog with: blogurl - blogname [num posts]
print ''.ucfirst($blogname[0]).' ~ <small>['.$blog['postcount'].' post(s)]</small><br/>';
endforeach;
?>
</div>
P/S: this code will show domain blog itself. someone can tell me how to remove/hidden it?
what is ucfirst in code how to function it?
*Admin please edit this post title to "Active Blog & Num of Posts" thankyou.
Here is some better code. The code will list like this:
<a href="blog url" title="blog name">blog name</a>
==============
<? $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE last_updated!='0000-00-00 00:00:00' ORDER BY last_updated DESC LIMIT 100");
foreach ($blogs as $blog) :
$blog = "wp_".$blog."_options";
$opt = $wpdb->get_col("SELECT option_value FROM $blog WHERE option_name='siteurl'");
$opt2 = $wpdb->get_col("SELECT option_value FROM $blog WHERE option_name='blogname'");
print "<li>• <a href='$opt[0]' title='$opt2[0]'>".ucfirst($opt2[0])."</a></li>";
endforeach;
?>
==============
I hope this helps someone as it helped me.