CyStats getMostVisited() line breaks

December 8, 2008 - Views: 449
Category: Web Development

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 &nbsp; because of line break
      echo str_replace("&nbsp;", " ", $out[$i]);
      $i++;
    }
  ?>
</ul>
</div>

Download CyStats from here:
http://wordpress.org/extend/plugins/cystats/

  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • MisterWong
  • Yigg
  • Technorati
  • Blogosphere News
  • LinkArena
  • Webnews.de

Tags: ,

Related Posts:

1 Response

  1. [...] 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. [...]

Leave a Reply

Home | Imprint | Impressum | Archiv
© 2008 M.Sc. Dipl.Inf. Michael Kolb. Powered by Wordpress. HTML CSS
my technorati | my blogcatalog