Get comment count for File Pages

WP-Filebase Pro Forums General Support Get comment count for File Pages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7797
    Sean Byrnes
    Participant

    Not sure if this is possible already, I can’t see a template tag for this.

    What I’m currently trying to do is display the number of comments a file has while browsing a list of files, like this:

    <?php echo wp_count_comments(%file_post_id%)->approved; ?>

    However this obviously doesn’t work since %file_post_id% means nothing to the wp_count_comments function.

    What would I need to replace this with, or maybe could a template tag be added for this functionality?

    • This topic was modified 8 years, 1 month ago by Sean Byrnes.
    #7806
    Fabian
    Participant

    Hi, try <?php echo wp_count_comments($f->file_post_id)->approved; ?>

    #7839
    Sean Byrnes
    Participant

    That looked good, but for some reason $f->file_post_id keeps returning 0.

    I’m using this code in the “Templates and Scripts” tab, editing the Default File Template in case you needed to know that.

    Any other ideas? Thanks though!

    #7840
    Sean Byrnes
    Participant

    Also $f->post_id is just blank, thought I’d give that a try.

    #7854
    Fabian
    Participant

    Sorry, try <?php echo wp_count_comments($f->file_wpattach_id)->approved; ?>
    file_wpattach_id is the correct ID of the file page, whereas file_post_id is the ID of the post the file is attached to.

    #7883
    Sean Byrnes
    Participant

    Yep, that worked great, thanks a lot!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.