Nov 17 2008

Adding a FanUpdate Entry Word Count

This is a rough 30-second guide, code is short & sweet, and I’ve not run the mod past Jenny… but, I’m not one to refuse a request when it’s simple to implement.

In your fanupdate folder (or the root of your website if that’s where you’ve got it installed), open the class folder, and find FanUpdate_Post.php.

Right near the very bottom of the file, look for:
$text = str_replace('{{body}}', $this->getBodyFormatted(), $text);

On a new line right after that one, add:
$text = str_replace('{{word_count}}', str_word_count($this->getBody()), $text);

Now, in your blog control panel, go to Options -> Templates, and in the entry_template: box put {{word_count}} where you’d like the word count to appear. E.g. on a default install, I edited the following line:
<p class="catfile">Posted {{date}}. Filed under {{category}}. {{comment_link}}. Word Count: {{word_count}}</p>

Save your settings and refresh your blog, it should appear exactly where you placed it.

Warning

This post is over 6 months old. This means that, despite my best intentions, it may no longer be accurate. Age, motherhood, experience, loss... these things have all changed me from when this blog was started back in the heady (ha) days of my youth.

As much as I would like to go back and edit 10 years of archives to provide an insight into the 'me' of now — to update coding snippets and revise website advice — it would probably take years to do so (by which point I'd have to start again!) This would defeat the point of keeping these archives anyway.

Please take these posts for what they are: a brief look into my past, my history, my journey.

6 Responses so far
  1. Julia says: November 17, 2008 at 8:24 pm # ·

    I don’t get the point of word count in blog entries. It’s doesn’t even look “cool”.

  2. Jem says: November 17, 2008 at 8:31 pm # ·

    Don’t ask me, I’m just doing as I’m told ;)

  3. Kim says: November 17, 2008 at 8:35 pm # ·

    Thanks for this Jem, it was very useful. :)

  4. Kim says: November 17, 2008 at 8:37 pm # ·

    Damn, clicked submit before I was finished. =/
    Also wanted to say:
    I tested it out and it worked… Not that I’ll probably keep it but it was useful to play with.

  5. Alexandra says: November 18, 2008 at 1:35 am # ·

    Thanks for that Jem, I’ll bookmark this entry for later ^_^

  6. Julia says: November 18, 2008 at 4:31 am # ·

    Thanks for this, I doubt I’ll ever use it. I want to try it out but my site is down :(

    It probably is 30secs.