Ashley Cameron Design

Ashley Cameron Design

Shop the Creative Design Market

Good morning

Bootstrap Comments function for WordPress

This post was last updated: Sep 3, 2020
SnippetsWordPress

About a 1 minute read

"Design is not just what it looks like and feels like. Design is how it works."

Steve Jobs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php      
// Comment Layout
function bones_comments($comment, $args, $depth) {
   $GLOBALS['comment'] = $comment; ?>
    <li <?php comment_class(); ?>>
        <article id="comment-<?php comment_ID(); ?>" class="clearfix">
            <div class="comment-author vcard row-fluid clearfix">
                <div class="avatar span3">
                    <?php echo get_avatar( $comment, $size='75' ); ?>
                </div>
                <div class="span9 comment-text">
                    <?php printf('<h4>%s</h4>', get_comment_author_link()) ?>
                    <?php edit_comment_link(__('Edit','bonestheme'),'<span class="edit-comment btn btn-small btn-info"><i class="icon-white icon-pencil"></i>','</span>') ?>
                   
                    <?php if ($comment->comment_approved == '0') : ?>
                        <div class="alert-message success">
                        <p><?php _e('Your comment is awaiting moderation.','bonestheme') ?></p>
                        </div>
                    <?php endif; ?>
                   
                    <?php comment_text() ?>
                   
                    <time datetime="<?php echo comment_time('Y-m-j'); ?>"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php comment_time('F jS, Y'); ?> </a></time>
                   
                    <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
                </div>
            </div>
        </article>
    <!-- </li> is added by wordpress automatically -->
<?php
} // don't remove this bracket!

// Display trackbacks/pings callback function
function list_pings($comment, $args, $depth) {
       $GLOBALS['comment'] = $comment;
?>
        <li id="comment-<?php comment_ID(); ?>"><i class="icon icon-share-alt"></i>&nbsp;<?php comment_author_link(); ?>
<?php

}

// Only display comments in comment count (which isn't currently displayed in wp-bootstrap, but i'm putting this in now so i don't forget to later)
add_filter('get_comments_number', 'comment_count', 0);
function comment_count( $count ) {
    if ( ! is_admin() ) {
        global $id;
        $comments_by_type = separate_comments(get_comments('status=approve&post_id=' . $id));
        return count($comments_by_type['comment']);
    } else {
        return $count;
    }
}
?>