CyStats is one of the most popular statistic modules for wordpress. Inside this blog, I’ve also used CyStats and the API function “getMostVisited()” to show most popular posts on sidebar.
To show most popular posts, you need to call the getMostVisited() function in your sidebar.php. If you do so, you will get some trouble with linebreaks, because the delivered code contains “nbsp” tags. You need to replace these tags by a blank.
Below my sidebar.php API call with replacement of “nbsp” tags to show most popular posts in wordpress cms:
<div id="yourid" class="widget">
<h2 class="title">Popular Posts</h2>
<ul>
<?php
$out = cystats_getMostVisited(5,'<li>','</li>',false);
$i = 0;
while($i < count($out))
{
// replace because of line break
echo str_replace(" ", " ", $out[$i]);
$i++;
}
?>
</ul>
</div>
Download CyStats from here:
http://wordpress.org/extend/plugins/cystats/







Michael Kolb » Blog Archive » CyStats widget shows most popular posts
December 14th, 2008
[...] In past, this function must be coded manually in sidebar.php. I’ve already written an article about the line break problems and how to integrate this function into sidebar.php. Find the aritcle here. [...]