I'm making a plugin which stores referrer data for comments. I already have my database table created, and the data is being stored correctly when a comment is made.

Now I would like to attach a custom div to the comment block for each comment. How would I add a filter to the comment loop? I want to say "if this comment ID has a referrer logged in my table, then print out the referrer in my special div". I can write the function myself, I just need help on where to inject my function.

1 Answer 1


It is hard to say what you need to hook into without knowing all the details but I think you may be able to use comment_text-- more or less the the_content of comments.

  function ($comment) {
    return $comment.'<div>This is your special division</div>';

If that isn't quite right, take a look at the filters listed in the Codex for comments.

  • That sounds perfect. I'll try that next week and let you know. Thanks very much!
    – Branndon
    Commented Sep 27, 2013 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.