Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers

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).

share|improve this answer
    
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 Jan 26 '11 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 Feb 24 '11 at 17:23
add comment

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

share|improve this answer
    
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 Jan 26 '11 at 9:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.