One Response

  1. Konstantin Kovshenin
    Konstantin Kovshenin Published |

    Wow! This is amazing. I did try something similar in the past, but it didn’t work for me for some reason. I like your approach and I think it can work. However, you should consider prefixing actions and filters, for the same reason you prefix functions and classes.

    Cheers and keep up the awesome stuff!

  2. Pippin
    Pippin Published |

    I love the idea but I really don’t think this should be in a theme; it should be built as a plugin designed to complement a theme. Imagine what would happen if someone populated their site with tons of “chat” posts and then switched themes: all of their chats would be broken (missing formatting at least).

    1. Andres Hermosilla
      Andres Hermosilla Published |

      P2 theme breaks the plugin/theme rule divide and it was created by Auttomatic. I think it’s a matter of using your best judgement.

    2. Shea Bunge
      Shea Bunge Published |

      Funny you should mention it, but I’m working on a a plugin like that.

  3. Matt
    Matt Published |

    I never even knew there was a chat function… thanks!

  4. Amy Hendrix
    Amy Hendrix Published |

    I love the filter approach (and I’ve really never seen a proper implementation of the post format in the wild), but the markup seems like a lost opportunity for my very favorite woefully underused element, the definition list — it’d save you a bunch of divs and classes, not to mention that it’s semantically perfect for pairs of names and values!

    1. Jesper
      Jesper Published |

      According to this article on 24ways you shouldn’t use definition lists for dialogues and explains why.

      I was thinking the same thing yesterday when I saw the code.

  5. Edward Caissie
    Edward Caissie Published |

    Very interesting … and somewhat timely as I am looking at how to implement an appropriate “Chat” format in one of my current projects.

  6. Frances
    Frances Published |

    Very handy. I’ve just been working on somewhat customised post formats for a blog and I never thought, “Oh, chats, they can be between more than two people, no?”

    I also marked it up using definition lists, and was really surprised at the Working Draft you posted, as I remember from somewhere suggested use for dl was e.g. marking up a script with dialogue.

    (HTML4 and XHTML2 working drafts both say “Another application of dl, for example, is for marking up dialogues, with each dt naming a speaker, and each dd containing his or her words.”)

  7. The Frosty
    The Frosty Published |

    This would make for a great plugin as well.

  8. Dougal Campbell
    Dougal Campbell Published |

    My handling of chats in my Formattd theme was a little more simplistic, but had a similar idea:

    It generates markup like
    <p class="chat"><span class="person person-bob">Bob:</span> Hi, Alice!</p>

    I thought I was being pretty clever with my ‘person-NAME’ classes, at the time. But ‘speaker-N’ is much more practical in real use.

  9. Vix
    Vix Published |

    This filter approach is much more powerful and you’ve both accounted for the fact that their might be colons within chat content.

    I’ve just been working with the styles – never occurred to me to use a filter.

  10. David Chandra
    David Chandra Published |

    thank you justin.
    you are too kind.
    my original code is very messy, and you clean it, and optimize it.
    it’s readable now 🙂

    can’t wait for the next series.

    Theme Hybrid forum is the best WordPress forum.

  11. Brutally Succinct: curating web designer resources | Post Formats: Chat
  12. Philip Newcomer
    Philip Newcomer Published |

    This is great! One observation, however: you have the separator hard-coded into line 51, although you’ve made provision for filtering it earlier. Shouldn’t line 51 be:

    $chat_row_split = explode( $separator, trim( $chat_row ), 2 );

    instead of

    $chat_row_split = explode( ':', trim( $chat_row ), 2 );

    Or am I missing something?

    If this is true, I can’t believe I actually found a bug in the mighty Justin Tadlock’s code! 🙂

  13. Shea Bunge
    Shea Bunge Published |

    Are you planning to post a guideline to implementing the link post format soon? I’d really appreciate it. 🙂

  14. Fyord
    Fyord Published |

    I’m confused, is this just comments made to look a little more like a chat room conversation?

  15. Benni
    Benni Published |

    Wow! This is awesome! This saved me hours of thinking and getting a headache while doing so 🙂

    Best regards,

  16. Kevin
    Kevin Published |

    Thanks for the script it works great.

    I did notice on testing that if you password protect a chat post, the following displays prior to the post password protected message.

    ://localhost/wp361_test/wp-login.php?action=postpass" method="post">

    It is fixed by adding the following at the beginning :

    if( post_password_required() )
    return $content;
  17. Jim
    Jim Published |

    can you please explain how to get this working with get_the_content ?

    thank you

  18. Shabby
    Shabby Published |

    I finally figured out how to do a chat post format thanks to this. I did encounter a problem though when I had my chat post password protected. Please see screenshot:–Wala_pa_rin_sweldo-_2014-02-05_161314_zpsd8f573fc.png

    Help please?

  19. Shabby
    Shabby Published |

    Oops, should have checked the comments first. Gonna try then the suggested solution.

  20. Jade -- NOT a developer
    Jade -- NOT a developer Published |


    You’re amazing. I got so tired of sifting through millions of themes to find the one that had the right look AND supported the chat post formats. They’re like unicorns!!

    So I thought.. maybe I can add this function to any theme and found this. WOW.

    I have a few questions, please keep in mind I’m not a developer and barely know how to code. I implemented the code above and it’s worked wonders on my test blog, but I’d like to make adjustments and am not proficient.

    How do I keep the author and text on the same line but make every other author bold. Would it be possible for you to give me a quick example changes in the code?!! I’ll get the idea.

    Also, someone mentioned this should be a plugin not hardwired. Can I make my own plugin with this code????

    Thanks so much, it’s already a million times better than it was.


  21. Courtney Robertson
    Courtney Robertson Published |

    Running into an error that shows a bit of code at the end of the chat post format only. See the code


    I can’t figure out where that last code is coming from. Any ideas?

  22. Helaine
    Helaine Published |

    Hello there! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept chatting about this. I will forward this write-up to him. Fairly certain he will have a good read. Many thanks for sharing!

Comments are closed.