WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Comment Bubbles Anyone? (11 posts)

  1. mqcarpenter
    Member
    Posted 6 years ago #

    I REALLY want to incorporate "comment bubbles" by my post listings on the sidebar and other post lists. I am referring to the exact feature shown in the admin panel here: Comment bubble in the admin panel. Has anyone seen a way to do this? I can not find a plugin or even a thread about it anywhere. Thanks

  2. whooami
    Member
    Posted 6 years ago #

    its just CSS applied to the span that contains the #.

    whats to pluginize? anything that displays comments can be done that way.

  3. mqcarpenter
    Member
    Posted 6 years ago #

    I am looking for the code to count the comments and display that element. I understand the design element of it in CSS. Looking at edit.php (which is the one that is in the screen shot) it appears that this may be it, but I am unsure:

    <?php
    
    if ( 1 == count($posts) && is_singular() ) :
    
    	$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
    	if ( $comments ) :
    		// Make sure comments, post, and post_author are cached
    		update_comment_cache($comments);
    		$post = get_post($id);
    		$authordata = get_userdata($post->post_author);
    	?>
  4. whooami
    Member
    Posted 6 years ago #

    display comments for what? for posts?

    thats already done on your permalink pages. Look at how its done there

    what you pasted, btw,

    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");

    will work, as well, as long as you pass the post_id to $id

  5. mqcarpenter
    Member
    Posted 6 years ago #

    What I am looking for is the code that creates this output:

    <td class="num"><div class="post-com-count-wrapper">
    		<a href='edit-pages.php?page_id=6' title='0 pending' class='post-com-count'><span class='comment-count'>0</span></a>		</div></td>

    I need to be able to set it up outside the blog folder, like the post list is through this:

    <?
    $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts
    WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
    foreach($news as $np){
    printf ("<li><a href=\"%s\">%s</a></li>", get_permalink($np->ID),$np->post_title);
    } ?>
  6. mqcarpenter
    Member
    Posted 6 years ago #

    Wow I am amazed that no one else has ever wanted to do this. It seems so simple, yet it alludes me. Has anyone done this?

  7. whooami
    Member
    Posted 6 years ago #


  8. whooami
    Member
    Posted 6 years ago #

    I put a - (dash) in there just so you could see the separation.

  9. whooami
    Member
    Posted 6 years ago #

    oops, I needed to close up a space and add the opening ul..

  10. whooami
    Member
    Posted 6 years ago #

    ok, here we go, and its valid.

    <ul>
    <?php
    $news=$wpdb->get_results("SELECT ID, post_title, comment_count FROM $wpdb->posts
    WHERE post_type = 'post' AND post_status ='publish' ORDER BY post_date DESC LIMIT 10");
    foreach($news as $np){
    echo "<li><a href=\"" .get_permalink($np->ID)."\">$np->post_title</a>-<span class=\"bubble\">$np->comment_count</span></li>";
    }
    ?>
    </ul>
  11. mqcarpenter
    Member
    Posted 6 years ago #

    whooami, you just made my WEEK! Thank you so much!

Topic Closed

This topic has been closed to new replies.

About this Topic