Created
June 9, 2025 07:00
-
-
Save KittenCodes/046988b055cb2583d54825a49ca01038 to your computer and use it in GitHub Desktop.
Comments Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* COMMENT HEADER */ | |
.comments .comment, | |
.comments .pingback, | |
.comments .trackback, | |
.comments .review { | |
padding-top: 3.5rem; | |
} | |
div.comment:first-of-type { | |
margin-top: 3.5rem; | |
padding-top: 0; | |
} | |
.comments .comments-header + div { | |
margin-top: 0; | |
padding-top: 0; | |
} | |
.comment-body { | |
position: relative; | |
} | |
.comment .comment { | |
padding-left: 5%; | |
} | |
.comment-meta { | |
line-height: 1.1; | |
margin-bottom: 1.5rem; | |
min-height: 5rem; | |
padding-left: 5rem; | |
position: relative; | |
} | |
.hide-avatars .comment-meta { | |
min-height: 0; | |
padding-left: 0; | |
} | |
.comment-meta a { | |
color: inherit; | |
} | |
.comment-author { | |
font-size: 1.8rem; | |
font-weight: 700; | |
letter-spacing: -0.027777778em; | |
} | |
.comment-author a { | |
text-decoration: underline; | |
} | |
.comment-author a:hover, | |
.comment-author a:focus { | |
text-decoration: none; | |
} | |
.comment-meta .avatar { | |
height: 4rem; | |
position: absolute; | |
left: 0; | |
top: 0; | |
width: 4rem; | |
} | |
.comment-author .url { | |
text-decoration: underline; | |
} | |
.comment-metadata { | |
color: #6d6d6d; | |
font-size: 1.4rem; | |
font-weight: 500; | |
margin-top: 0.6rem; | |
} | |
.comment-metadata a { | |
text-decoration: none; | |
} | |
.comment-metadata a:focus, | |
.comment-metadata a:hover { | |
text-decoration: underline; | |
} | |
/* COMMENT CONTENT */ | |
.comment-list, | |
.comment-list ol, | |
.comment-list li { | |
list-style: none; | |
margin: 0; | |
padding: 0; | |
} | |
.comment-list li::marker, | |
.comment-list ol li::marker { | |
display: none; | |
} | |
/* Optional: keep indentation via padding for nested replies */ | |
.comment .comment { | |
padding-left: 5%; | |
} | |
.comment-content.entry-content > *:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.is-style-wide) { | |
width: 100%; | |
} | |
.comment-content.entry-content .alignleft { | |
/*rtl:ignore*/ | |
margin-left: 0; | |
} | |
.comment-content.entry-content .alignright { | |
/*rtl:ignore*/ | |
margin-right: 0; | |
} | |
/* COMMENT FOOTER */ | |
.comment-footer-meta { | |
align-items: center; | |
display: flex; | |
flex-wrap: wrap; | |
font-size: 1.2rem; | |
font-weight: 600; | |
justify-content: flex-start; | |
letter-spacing: 0.030833333em; | |
line-height: 1; | |
margin: 1.5rem 0 -1rem -1.5rem; | |
text-transform: uppercase; | |
} | |
.comment-footer-meta > * { | |
margin: 0 0 1rem 1.5rem; | |
} | |
.comment-reply-link { | |
background-color: #cd2653; | |
color: #fff; | |
display: block; | |
padding: 0.7rem; | |
} | |
.bypostauthor .comment-footer-meta .by-post-author { | |
display: block; | |
} | |
.comment-footer-meta a { | |
text-decoration: none; | |
} | |
.comment-footer-meta a:focus, | |
.comment-footer-meta a:hover { | |
text-decoration: underline; | |
} | |
/* Pingbacks & Trackbacks ------------------------- */ | |
.pingback .comment-meta, | |
.trackback .comment-meta { | |
padding-left: 0; | |
} | |
/* Comments Pagination ---------------------------- */ | |
.comments-pagination { | |
display: flex; | |
flex-wrap: wrap; | |
justify-content: space-between; | |
margin-top: 6rem; | |
text-align: center; | |
} | |
.comments-pagination.only-next { | |
justify-content: flex-end; | |
} | |
.comments-pagination .page-numbers { | |
display: none; | |
text-decoration: none; | |
} | |
.comments-pagination .page-numbers:focus, | |
.comments-pagination .page-numbers:hover { | |
text-decoration: underline; | |
} | |
.comments-pagination .prev, | |
.comments-pagination .next { | |
display: block; | |
} | |
.comments-pagination .prev { | |
left: 0; | |
} | |
.comments-pagination .next { | |
right: 0; | |
text-align: right; | |
} | |
/* Comment Respond ---------------------------- */ | |
.comment-respond::after { | |
clear: both; | |
content: ""; | |
display: block; | |
} | |
.comment-respond .comment-notes, | |
.comment-respond .logged-in-as { | |
color: #6d6d6d; | |
font-size: 1.6rem; | |
line-height: 1.4; | |
margin: -3rem 0 4rem 0; | |
text-align: center; | |
} | |
.comment-respond .required-field-message { | |
display: inline-block; | |
} | |
.comment-respond p { | |
line-height: 1.1; | |
margin-bottom: 2rem; | |
margin-left: auto; | |
margin-right: auto; | |
} | |
.comment-respond p:not(.comment-notes) { | |
max-width: 58rem; | |
} | |
.comment-form-cookies-consent { | |
align-items: baseline; | |
display: flex; | |
} | |
.comment-respond > p:last-of-type { | |
margin-bottom: 0; | |
} | |
.comment-respond label { | |
display: block; | |
} | |
.comment-respond input[type="checkbox"] + label { | |
font-size: 1.5rem; | |
line-height: 1.25; | |
} | |
.comment-respond input[type="text"], | |
.comment-respond input[type="email"], | |
.comment-respond textarea { | |
margin-bottom: 0; | |
} | |
.comment-respond textarea { | |
height: 15rem; | |
} | |
.comment-respond #submit { | |
display: block; | |
} | |
.comment-respond .comments-closed { | |
text-align: center; | |
} | |
/* Reply Respond ---------------------------- */ | |
.comments .comment-respond { | |
padding: 3rem 0 0; | |
} | |
.comments .comment-respond .comment-reply-title, | |
.comments .comment-respond .comment-notes, | |
.comments .comment-respond .logged-in-as { | |
text-align: left; | |
} | |
.comment-reply-title small { | |
display: block; | |
font-size: 1.6rem; | |
font-weight: 600; | |
letter-spacing: -0.0277em; | |
margin: 0.5rem 0 0 0; | |
white-space: nowrap; | |
} | |
.comment-reply-title small a { | |
text-decoration: none; | |
} | |
.comment-reply-title small a:focus, | |
.comment-reply-title small a:hover { | |
text-decoration: underline; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$post_id = get_the_ID(); | |
$comments = get_comments([ | |
'post_id' => $post_id, | |
'status' => 'approve', | |
'orderby' => 'comment_date_gmt', | |
'order' => 'ASC', | |
]); | |
if (!empty($comments)) { | |
?> | |
<h2 class="comment-reply-title"> | |
<?php echo sprintf( | |
_n('%s reply on “%s”', '%s replies on “%s”', count($comments), 'your-textdomain'), | |
number_format_i18n(count($comments)), | |
get_the_title($post_id) | |
); ?> | |
</h2> | |
<div class="comments"> | |
<ol class="comment-list"> | |
<?php | |
wp_list_comments([ | |
'style' => 'ol', | |
'avatar_size' => 80, | |
'format' => 'html5', | |
'callback' => 'custom_theme_comment', | |
], $comments); | |
?> | |
</ol> | |
</div> | |
<?php | |
} | |
// Custom callback for comment markup | |
function custom_theme_comment($comment, $args, $depth) { | |
$tag = $args['style'] === 'div' ? 'div' : 'li'; | |
?> | |
<<?php echo $tag; ?> <?php comment_class($comment->comment_type); ?> id="comment-<?php comment_ID(); ?>"> | |
<article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> | |
<footer class="comment-meta"> | |
<div class="comment-author vcard"> | |
<?php echo get_avatar($comment, $args['avatar_size']); ?> | |
<?php | |
printf( | |
'<b class="fn">%s</b> <span class="says">says:</span>', | |
get_comment_author_link() | |
); | |
?> | |
</div><!-- .comment-author --> | |
<div class="comment-metadata"> | |
<a href="<?php echo esc_url(get_comment_link($comment->comment_ID)); ?>"> | |
<time datetime="<?php comment_time('c'); ?>"> | |
<?php comment_date(); ?> at <?php comment_time(); ?> | |
</time> | |
</a> | |
<?php edit_comment_link(__('Edit'), '<span class="edit-link"> • ', '</span>'); ?> | |
</div><!-- .comment-metadata --> | |
</footer><!-- .comment-meta --> | |
<div class="comment-content entry-content"> | |
<?php comment_text(); ?> | |
</div><!-- .comment-content --> | |
<footer class="comment-footer-meta"> | |
<?php | |
comment_reply_link([ | |
'depth' => $depth, | |
'max_depth' => $args['max_depth'], | |
'reply_text'=> 'Reply', | |
'before' => '<span class="comment-reply">', | |
'after' => '</span>', | |
]); | |
?> | |
</footer><!-- .comment-footer-meta --> | |
</article><!-- .comment-body --> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment