WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] iterate thorugh wp_list_comments

[Resolved] iterate thorugh wp_list_comments

  • Is there a way to have a counter inside wp_list_comments so I can put random content in the middle of the comments list with PHP?

    For example: I use wp_list_comments to display 15 comments per page. I want to put a banner every between 5th and 6th comments, a link between 12 and 13th, etc.

    Is there a way of doing it with a callback function?

Viewing 2 replies - 1 through 2 (of 2 total)
  • So i guess it really is not possible, right? 🙁

    Well, i found a way. I am gonna explain here for someone who runs through the same problem.

    I wanted to have:
    ———————
    Comment 1
    ———————
    Comment 2
    ———————
    Comment 3
    ———————
    Some stuff (an ad, for instance)
    ———————
    Comment 4
    (…)

    I couldn’t find a way to put a counter in the wp_list_comments function, but then I found Greg’s Threaded Comment Counter, by Greg Mullhouser.

    The plugin does the counting for only top-level comments or for the level that you specify in the settings. Top-level was what I wanted. The problem, for me, is that it echoes the numbers.

    I changed the “echo” for “return” and it now works the way I want. It is not the perfect solution, but it is working.

    So, if someone runs into another solution, I would be glad to know.

    frq.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] iterate thorugh wp_list_comments’ is closed to new replies.
Skip to toolbar