WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] iterate thorugh wp_list_comments (3 posts)

  1. frq
    Member
    Posted 4 years ago #

    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?

  2. frq
    Member
    Posted 4 years ago #

    So i guess it really is not possible, right? :-(

  3. frq
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic