워드프레스 댓글 안 나오는 문제 해결하기

언제부턴가 댓글이 표시되지 않았다. 거의 같은 스킨의 다른 블로그가 있어서 그걸 확인해봤더니 거긴 댓글이 나오더라. 거긴 플러그인이나 워드프레스 버전이 낮았는데 하나하나 업그레이드 해보면서 혹시 플러그인 문제인지 확인해보기로 했다.

그랬더니 아키스밋 스팸 방지 플러그인을 업그레이드 하자 댓글이 표시되지 않는 문제를 확인할 수 있었다. 그런데 더 이상한 점은 그 플러그인을 비활성화하거나 제거해도 댓글이 표시되지 않는 현상은 해결되지 않았다는 것이다.

그래서 이번에는 스킨(테마)을 변경해봤다. 그랬더니 댓글이 잘 표시됐다. 이 블로그의 테마 디자인은 twentyten이라는 테마를 내식대로 고친 것인데 워낙 오래전의 스킨이라서 뭔가 워드프레스 새 버전의 변경된 부분과 연결이 어긋나는 부분이 생긴 것 같았다.

그런데 막막했다. 내가 php를 잘 아는 것도 아니고 테마의 어떤 부분을 고쳐야 댓글이 표시된단 말인가? 그러다가 문득 twentyten라는 원래 테마를 설치해보기로 했다. 그랬더니 댓글이 잘 나왔다. twentyten 테마의 디자인은 거의 안 바뀌었지만 워드프레스 버전이 올라가면서 해당 스킨도 어느정도 패치가 조금씩 이루어졌기 때문인 것 같다.

그래서 현재 나의 테마와 twentyten의 테마의 차이점을 찾기 시작했다. php파일을 하나씩 교체해보기도 하고 코드의 차이를 확인해보면서 말이다. 그러다가 찾았다. 테마 함수 (functions.php)에서 댓글 부분을 교체했더니 댓글이 잘 표시되었다.

정확한 코드인지는 모르겠으나 기존에 비슷한 comment 함수 코드를 아래의 새로운 코드로 바꿔주면 댓글이 표시될 것이다. (확실하진 않으니 만약 나와 같은 문제가 있다면 직접 가장 최신의 테마를 받아서 기존의 코드를 신규 코드로 교체해주는게 좋을 것 같다.)

if ( ! function_exists( 'TwentyTen_gryeo_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own TwentyTen_gryeo_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since Twenty Ten 1.0
*
* @param object $comment The comment object.
* @param array $args An array of arguments. @see get_comment_reply_link()
* @param int $depth The depth of the comment.
*/
function TwentyTen_gryeo_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case '':
case 'comment':
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 40 ); ?>
<?php
/* translators: %s: Author display name. */
printf( __( '%s <span class="says">says:</span>', 'TwentyTen_gryeo' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) );
?>
</div><!-- .comment-author .vcard -->
<?php
$commenter = wp_get_current_commenter();
if ( $commenter['comment_author_email'] ) {
$moderation_note = __( 'Your comment is awaiting moderation.', 'TwentyTen_gryeo' );
} else {
$moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.', 'TwentyTen_gryeo' );
}
?>
<?php if ( '0' == $comment->comment_approved ) : ?>
<em class="comment-awaiting-moderation"><?php echo $moderation_note; ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: Date, 2: Time. */
printf( __( '%1$s at %2$s', 'TwentyTen_gryeo' ), get_comment_date(), get_comment_time() );
?>
</a>
<?php
edit_comment_link( __( '(Edit)', 'TwentyTen_gryeo' ), ' ' );
?>
</div><!-- .comment-meta .commentmetadata -->
<div class="comment-body"><?php comment_text(); ?></div>
<div class="reply">
<?php
comment_reply_link(
array_merge(
$args,
array(
'depth' => $depth,
'max_depth' => $args['max_depth'],
)
)
);
?>
</div><!-- .reply -->
</div><!-- #comment-## -->

This entry was posted in 블로그, 워드프레스, HTML, 잡담. Bookmark the permalink.

댓글 남기기