코멘트 타입 구분 나열
[ Plugin / Sort Comment Type / Leave Comment ]
- 메인 화면에는 코멘트 수와 트랙백 수를 합친 코멘트 수를 표기함. (따로 나누고 싶은 경우 Trackping Separator 플러그인을 참고
- 코멘트 타입 - 디비에 저장되는 타입명
- 트랙백 - trackback
- 핑백 - pingback
- 일반 코멘트 - 없음
- 관리자 코멘트 - 없음
- 비밀 코멘트 (Whisper 플러그인 사용할 때) - whisper:숫자
- 타입 구분할 때
간단하게
<?php if (get_comment_type() == "pingback") {어쩌구;} ?>- 또 다른 방법
<?php global $comment; /* 디비에 저장되는 코멘트 타입명에 whisper라는 글자가 있는지 확인해봄.*/ if (stristr($comment->comment_type,'whisper')) {어쩌구;} 혹은 if (preg_match('|whisper|', $comment->comment_type)) {어쩌구;} ?> - 위를 함수로 만듦
function k2_comment_type_detection($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback', $secrettxt = 'Secret') { global $comment; if (preg_match('|trackback|', $comment->comment_type)) return $trackbacktxt; elseif (preg_match('|pingback|', $comment->comment_type)) return $pingbacktxt; elseif (preg_match('|whisper|', $comment->comment_type)) return $secrettxt; else return $commenttxt; }- 사용시 :
<?php if (k2_comment_type_detection() == "Secret") {어쩌구;} ?>
- 사용시 :
- 쓴 사람에 따른 코멘트 구분
<?php $isByAuthor = false; if($comment->comment_author_email == '이메일@주소.com') { $isByAuthor = true; } ?>- 사용시 :
<?php if ($isByAuthor ) {어쩌구;} ?>
- 사용시 :
Categories : Wordpress