0

Wordpress founder, Matt Mullenweg, has a great feature in his photo galleries. In thumbnail view, any photo that has a comment attached displays the comment count under the thumbnail.

Look here (scroll down and you'll see some thumbnails with comment counts): http://ma.tt/2010/11/luxembourg/

He appears to be using the built-in gallery function, but I have been scouring the internet and cannot find any way to do this. Any help would be appreciated. Thanks!

EDIT: It should also be noted that in this particular case I actually don't need the standard captions to show at all. Instead of adding the comment-count to the caption, I would be happy with a way to replace the standard caption with the comment count. I'm not sure if this make things any easier. Thanks!

2 Answers 2

1

From the looks of Matt's page he's running a filter on either the img or gallery shortcode and replacing the caption with the comment count.

I've answered two related questions on how to modify the img and gallery shortcode functions, see.

How to customize the default HTML for Wordpress Attachments
How to customise the output of the WP image gallery shortcode from a plugin?

What i think you'd be aiming to do here is selectively add a filter onto one of the shortcodes and change the caption text for the comment count(as it appears is done on Matt's website).

2
  • Thanks for the great information! I'll have to dig into this a little further as it seems a little over my head. Hopefully I can figure it out.
    – user2738
    Commented Jan 26, 2011 at 20:23
  • If you're happy you've been given the necessary information to answer the original question please consider marking the appropriate answer as correct. If you feel the question was not sufficiently answered please let us know.
    – t31os
    Commented Feb 24, 2011 at 17:23
0

What you are probably looking for is comment_number() or get_comments_number() depending if you want it formatted or just the number.

1
  • And remember that you want the comments on the attachment, not on the main post. get_comments_number() accepts a $post_id parameter, that's where you pass the attachment id.
    – Jan Fabry
    Commented Jan 26, 2011 at 9:08

Your Answer

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