How to display total Post Count and Word Count of blog?
-
I’ve found this “Post Count” and “Word Count” plugins, but they only support old versions (1.2 and 1.5) of WP.
If anyone knows how to modify these little code snippets to work with WP v2.x, please advise!
######################
POST COUNT for WP v1.5
######################<?php
/*
Plugin Name: Post Count
Plugin URI: https://mtdewvirus.com/code/wordpress-plugins/
Description: Outputs the total number of posts.
Version: 1.1
Author: Nick Momrik
Author URI: https://mtdewvirus.com/
*/function mdv_post_count() {
global $wpdb;
echo $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_date_gmt < ‘” . gmdate(“Y-m-d H:i:s”,time()) . “‘”);
}
?>##########################
POST WORD COUNT for WP 1.5
##########################<?php
/*
Plugin Name: Post Word Count
Plugin URI: https://mtdewvirus.com/code/wordpress-plugins/
Description: Outputs the total number of words in all posts.
Version: 1.02
Author: Nick Momrik
Author URI: https://mtdewvirus.com/
*/function mdv_post_word_count() {
global $wpdb;
$now = gmdate(“Y-m-d H:i:s”,time());
$words = $wpdb->get_results(“SELECT post_content FROM $wpdb->posts WHERE post_status = ‘publish’ AND post_date < ‘$now'”);
if ($words) {
foreach ($words as $word) {
$post = strip_tags($word->post_content);
$post = explode(‘ ‘, $post);
$count = count($post);
$totalcount = $count + $oldcount;
$oldcount = $totalcount;
}
} else {
$totalcount=0;
}
echo number_format($totalcount);
}
?>
- The topic ‘How to display total Post Count and Word Count of blog?’ is closed to new replies.