I used to use the WordPress plugin Counterize II to keep track of my blog’s statistics, but then I felt that I had to switch into something else. I looked for another feature-rich stats plugin but one that is faster and that will take up less database space. After trying different plugins, I chose to stick with CyStats.
The only thing I needed but didn’t get (right away) from CyStats is the code to insert into my themes in order to call functions to return values like the total number of hits, total number of comments, total number of posts, and such. Maybe there’s a web page lying around in the Internet and I simply did not search thoroughly that I wasn’t able to find it. And since I didn’t find it, I’m making my own list of template tags (template functions) here, hoping that it would help other users.
By the way, I got all these from the template-functions.php
which is inside the /includes
folder of the plugin. I’m putting a list here just to make our task easier. 😀
CyStats template tags/functions:
-
Show number of blog posts
» Returns an integer
1<?php echo cystats_countPosts($showmode=TRUE); ?> -
Show number of approved comments
» Returns an integer
1<?php echo cystats_countComments($showmode=TRUE); ?> -
Show number of authors
» Returns an integer
1<?php echo cystats_countAuthors($showmode=TRUE); ?> -
Show number of published pages
» Returns an integer
1<?php echo cystats_countPages($showmode=TRUE); ?> -
Show number of links
» Returns an integer
1<?php echo cystats_countLinks($showmode=TRUE); ?> -
Show number of categories
» Returns an integer
1<?php echo cystats_countCategories($showmode=TRUE); ?> -
Show number of days since the first blog post
» Returns an integer
1<?php echo cystats_firstPostDays($showmode=TRUE); ?> -
Show the date when the first blog entry was posted
» Returns a string
1<?php echo cystats_firstPost($showmode=TRUE); ?> -
Show number of blog users in the database
» Returns an integer
1<?php echo cystats_countUsers($showmode=TRUE); ?> -
Show the names of top commenters
» Returns strings
1<?php echo cystats_getTopCommenters($topcount, $pre='', $pos='', $showmode=TRUE); ?> -
Show number of feed readers today
» Returns an integer
1<?php echo cystats_countFeedreadersToday($showmode=TRUE); ?> -
Show the number of users online
» Returns an integer
1<?php echo cystats_countUsersOnline($showmode=TRUE); ?> -
Show the recent blog posts
» Returns an array of strings
1<?php echo cystats_getRecentPosts($limit, $pre='', $pos='', $showmode=TRUE); ?> -
Show the most commented blog posts
» Returns an array of strings
1<?php echo cystats_getMostCommented($limit, $pre='', $pos='', $showmode=TRUE); ?> -
Show the most visited blog posts
» Returns an array of strings
1<?php echo cystats_getMostVisited($limit, $pre='', $pos='', $showmode=TRUE); ?> -
Show post visits
» Returns an array
1<?php echo cystats_getPostVisitsByID($id,$showmode=TRUE); ?> -
Show recent comments
» Returns array of strings
1<?php echo cystats_getRecentCommented($limit, $pre='', $pos='', $showmode=TRUE); ?> -
Show total number of visits
» Returns an integer
1<?php echo cystats_countVisits($mode, $showmode=TRUE); ?> -
Show total number of hits
» Returns an integer
1<?php echo cystats_countHits($mode, $showmode=TRUE); ?> -
Show average number of posts per day
» Returns an integer
1<?php echo cystats_countAvgPostsPerDay($showmode=TRUE); ?> -
Show average number of comments per day
» Returns an integer
1<?php echo cystats_countAvgCommentsPerDay($showmode=TRUE); ?> -
Show the count of search engine referers
» Returns an integer
1<?php echo cystats_getSearchengineRefererCount($showmode=TRUE); ?>
Function Parameters:
- The boolean parameter $showmode echoes value when set to TRUE, while returns value when set to FALSE
- The integer parameter $topcount should be replaced with the number of (commenters) to get
- The string parameter
$pre=''
determines the string to set before each list item, e.g.$pre='<li>'
- The string parameter
$pos=''
determines the string to set after each list item, e.g.$pos='</li>'
- The integer parameter $limit should be replaced with the number of (posts) to get
- The integer parameter $id in the function cystats_getPostVisitsByID(); should replaced with the ID number of a post
- The string parameter $mode should be replaced with one of the following values:
today
,yesterday
,week
,month
,year
, orall
.
Please note that not all functions were tested, and that the listed items are subject to error. Feel free to comment on this post if you notice any. 🙂
1 |
<?php echo xxx; ?> |
-->