• Hi,

    Looks like comments_popup_link needs some work. As in it should only count the number of comments and display the link. At the moment it counts comments, pingbacks, and trackbacks all as comments. 🙁

    Would also be nice if too additional functions could be added, thinking something like “pingback_popup_link” and “trackback_popup_link”.

    Sadly it looks like that is how was about three years ago:

    http://trac.wordpress.org/changeset/104

    Please change this back or rename the function since it implies it only prints out the number of comments when in fact it does all three.

    So is there now no way to simply print out the real number of comments? pingbacks? trackbacks?

    Thanks a lot,

    Will

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter war59312

    (@war59312)

    Um, another function that assumes all three are comments:

    <?php $numOfComments = get_comments_number(); echo $numOfComments; ?>

    For example it will print “5” when there is 3 trackbacks and 2 comments. 🙁

    Thread Starter war59312

    (@war59312)

    Anyone got any ideas on how I can do this at least?

    Thread Starter war59312

    (@war59312)

    1 and only bump

    thanks!

    That’s pretty much the way things are: Comments, trackbacks and pingbacks are all treated the same.

    If you want to Present them differently, you certainly can. That’s something you do at the theme (presentation) level.

    For instance, I show all my trackbacks/pingbacks in a list first, then the comments.

    Thread Starter war59312

    (@war59312)

    Yes that is what I do now, but I just want to count them as what they really are. For example a topic has 15 comments, 5 trackbacks, and 3 pingbacks. Not 23 comments.

    Well… if you lump track/ping backs together, you could do something like this:

    <?php /* Count the totals */
    	$numPingBacks = 0;
    	$numComments  = 0;
    
    	foreach ($comments as $comment) {
    		if (get_comment_type() != "comment") {
    			$numPingBacks++;
    		} else {
    			$numComments++;
    		}
    	}
    	?>
    Thread Starter war59312

    (@war59312)

    Hi,

    Thanks, that works on comments.php within the loop, but not outside the loop, like on post.php.

    Sorry, should have mentioned it, I am looking to display the number of comments, number of trackbacks, and number of pingbacks, for each post via post.php outside the loop.

    Also, I noticed the above code works fine for comments but it treats trackbacks and pingbacks as one. Anyway to separate the two?

    Thanks again,

    Will

    I don’t have the entire answer, but maybe this’ll get you closer…

    On my blog, this query:

    SELECT comment_type, count( comment_type )
    FROM <code>wp_comments</code>
    WHERE comment_post_id =937
    GROUP BY comment_type

    (where 937 = post_id) results in:

    Count comment_type count( comment_type )
    30
    pingback 63
    trackback 3

    (pardon the formatting).

    Comments are blank. But pingback/trackbacks are differentiated at the db level, so there’s hope…

    Thread Starter war59312

    (@war59312)

    Hey,

    I got to really learn PHP and mysql one of these days… lol

    I am sure this sucks big time and it is much easier than this:

    <?php
    
    $numberOfComments = $wpdb->get_var("SELECT COUNT( comment_post_ID ) FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_type = '' GROUP BY 'comment_type' ");
    
    $numberOfTrackbacks = $wpdb->get_var("SELECT COUNT( comment_post_ID ) FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_type = 'trackback' GROUP BY 'comment_type' ");
    
    $numberOfPingbacks = $wpdb->get_var("SELECT COUNT( comment_post_ID ) FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_type = 'pingback' GROUP BY 'comment_type' ");
    
    	if ($numberOfComments != "" && $numberOfComments == 1) {
    
    		echo $numberOfComments; echo " comment ";
    
    		} else if ($numberOfComments > 1) {
    
    			echo $numberOfComments; echo " comments ";
    
    		}
    
    	if ($numberOfTrackbacks != "" && $numberOfTrackbacks == 1) {
    
    		echo $numberOfTrackbacks; echo " trackback ";
    
    		} else if ($numberOfTrackbacks > 1) {
    
    			echo $numberOfTrackbacks; echo " trackbacks ";
    
    		}
    
    	if ($numberOfPingbacks != "" && $numberOfPingbacks == 1) {
    
    		echo $numberOfPingbacks; echo " comment ";
    
    		} else if ($numberOfPingbacks > 1) {
    
    			echo $numberOfPingbacks; echo " comments ";
    
    		}
    
    ?>

    Take Care,

    Will

    Hi,

    Thanks, that works on comments.php within the loop, but not outside the loop, like on post.php.

    Sorry, should have mentioned it, I am looking to display the number of trackbacks, and number of pingbacks, for each post .

    please help me

    Thread Starter war59312

    (@war59312)

    I dont m8. I need some help still too…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘comments_popup_link Needs Work’ is closed to new replies.