• I’ve been searching all over for a plugin that counts the number of words in one post and displays it. I’ve tried several but they haven’t seemed to work. Can someone please give me a link to download one that I can use?

    For an example of an exact plugin, I want one that functions like Nuclear Moose’s Site.

    Thanks

Viewing 5 replies - 16 through 20 (of 20 total)
  • Brilliant!

    There was a space after the closing ?> in the plugin file which I deleted and now it works fine.

    Many thanks

    Thread Starter skankybeans

    (@skankybeans)

    I’m still getting an error in my code. To figure out exactly what is wrong in the code, I deleted, the comment section in the plugin so that I could figure out exactly what line I’m getting an error on. Here it is:
    global $wpdb, $tableposts, $id;

    And here is the code for the plugin that I have now:
    <?php
    function post_word_count() {
    ????????global $wpdb, $tableposts, $id;
    ????????$post = $wpdb->get_results("SELECT post_content FROM $tableposts WHERE id=$id");
    ????????$words = strip_tags($post[0]->post_content);
    ????????$words = explode(' ', $words);
    ????????$counting = count($words);
    ????????$counting = $counting;
    ????????$wordcount = number_format($counting);
    ????????echo $wordcount;
    }
    function total_word_count() {
    ????????global $wpdb, $tableposts;
    ????????$words = $wpdb->get_results("SELECT post_content FROM $tableposts WHERE post_status = 'publish'");
    ????????foreach ($words as $word) {
    ????????????????$post = strip_tags($word->post_content);
    ????????????????$post = explode(' ', $post);
    ????????????????$count = count($post);
    ????????????????$totalcount = $count + $oldcount;
    ????????????????$oldcount = $totalcount;
    ????????????????$finalcount = number_format($totalcount);
    ????????}
    ????????echo $finalcount;
    }
    function out_of_count() {
    ????????global $wpdb, $tableposts, $id;
    ????????$post = $wpdb->get_results("SELECT post_content FROM $tableposts WHERE id=$id");
    ????????$words1 = strip_tags($post[0]->post_content);
    ????????$words1 = explode(' ', $words1);
    ????????$counting = count($words1);
    ????????$counting = $counting;
    ????????$wordcount = number_format($counting) . " " . ($counting==1 ? "word" : "words");
    ????????$words = $wpdb->get_results("SELECT post_content FROM $tableposts WHERE post_status = 'publish'");
    ????????foreach ($words as $word) {
    ????????????????$post2 = strip_tags($word->post_content);
    ????????????????$post2 = explode(' ', $post2);
    ????????????????$count = count($post2);
    ????????????????$totalcount = $count + $oldcount;
    ????????????????$oldcount = $totalcount;
    ????????????????$finalcount = number_format($totalcount);
    ????????}
    ????????echo "$wordcount of $finalcount words";
    }
    ?>

    Thread Starter skankybeans

    (@skankybeans)

    I finally fixed the plugin and it’s working perfectly. I went back into my WordPress Admin and looked at the code for wordcount.php under the Templates section. I tried deleting every space for indenting and such and it fixed the problem. I’m so happy!

    Glad to hear you got it working, and thanks for posting your solution!

    Thread Starter skankybeans

    (@skankybeans)

    Always glad to be of help to others and I was just happy to get it working. Thanks for the help along that way. I appreciate it!

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Post Word Count Plugin?’ is closed to new replies.