• hey all,

    how can I set things up so that the number of comments left on an individual photo are displayed beneath that photo in the gallery.

    for instance:

    I upload some new photos and create a gallery. that gallery is inserted into the post and published. some people leave comments on the post itself, but others leave comments on individual photos.

    now when someone else comes along looking at the post, they’ll see that there are comments on the post, but they won’t know about the comments on individual photos unless they opened that photo themselves.

    what I would like to see is when looking at the original post with the gallery embedded, under a photo with comments, it should say “1 comment” or “2 comments” etc.

    Anybody know how to do that?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I can only find one way and that is to do some hard code in image.php
    You find image.php in the wp_include folder.

    in image.php approximately in line 449 (in wp 2.6) you will find following:

    foreach ( $attachments as $id => $attachment ) {
    		$link = wp_get_attachment_link($id, $size, true);
    		$output .= "<{$itemtag} class='gallery-item'>";
    		$output .= "
    			<{$icontag} class='gallery-icon'>
    				$link
    			</{$icontag}>";
    		if ( $captiontag && trim($attachment->post_excerpt) )
    		{
    			$output .= "
    				<{$captiontag} class='gallery-caption'>
    				{$attachment->post_excerpt}
    				</{$captiontag}>";
    		}
    		$output .= "</{$itemtag}>";
    		if ( $columns > 0 && ++$i % $columns == 0 )
    			$output .= '<br style="clear: both" />';
    	}

    I have replaced with following:

    foreach ( $attachments as $id => $attachment ) {
    		$link = wp_get_attachment_link($id, $size, true);
    		$output .= "<{$itemtag} class='gallery-item'>";
    		$output .= "
    			<{$icontag} class='gallery-icon'>
    				$link
    			</{$icontag}>";
    		if ( $captiontag && trim($attachment->comment_count) )
    		{
    			$antal=	$attachment->comment_count;
    			if ($antal=1)
    				{$output .= "<{$captiontag} class='gallery-caption'>1 comment</{$captiontag}>";}
    			else
    				{$output .= "<{$captiontag} class='gallery-caption'>".$antal." comments</{$captiontag}>";}
    		}

    this solution shows only a text if there is a comment.
    ($antal I’m danish, that’s why)
    you have to remember this next time there is an update (there have been changes in media.php during every single update since it was introduced)

    kind regards

    Mikael Boldt

    Is there a way to add comments under each picture?

    @miatalewis
    what do you mean?
    if you want comments under each picture in the gallery you have to include it in your Theme – image.php, where you have to add:

    <?php comments_template(); ?>

    kind regard

    Boldt

    These comments don’t seem to be counted, I have posts which show 0 comments but the individual pictures in the post do have comments.
    Is there a way to make them count?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘display photo comments in gallery?’ is closed to new replies.