Support » Fixing WordPress » How to retrieve last word from comment?

  • Im trying to implement some sort of “Exquisite corpse” (see wikipedia) using wordpress.

    The idea is to have a custom post type (done) for exquisite corpses. The post would be the rules and theme, etc. Then the readers would only see the last word from the last comment approved so they can submit their own comment continuing the story.

    I thought of having 2 post templates for this kind of post. The first would hide the published comments, showing only the last word from the last comment, and the submit box.

    Once its finished, I would switch to the second post template which would show all comments text one after the other, thus creating the story.

    But I need help retrieving the last word from the last approved comment.

    I can figure out the rest.

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I thing you can get this from php string function

    That won’t do the trick, if I understood it right, that will retrieve whatever is after the last instance of a given constant. For example, if the constant is a dot, in the following string…

    …it will return “org”.

    However, you did point me in the right direction. I searched there for “last word” and came up with this PHP function which I think will do the trick:


    Maybe I could use that to retrieve all words as an array and somehow discard all but the last item of that array?

    Any thoughts here? Im not that good at PHP, will appreciate the help.


    Think I got it…

    $last = end($array);

    Still havent tried all this yet, but in theory it loooks flawless.

    Do I smell a 3-people-in-the-world-could-find-the-useful plugin here? And I’m not even counting me in 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to retrieve last word from comment?’ is closed to new replies.