부등호(< , >)를 < ; 및 > ;로 변환하는 툴
워드프레스에서는 보안을 위해 보통 댓글에 HTML 태그가 허용되지 않습니다. HTML 태그를 입력하면 태그가 누락되어 코드가 제대로 입력되지 않습니다. 워드프레스에서 댓글을 달 때 HTML/PHP 코드를 입력할 때에는 <와 >를 < ; , > ;로 변환한 후에 입력하면 됩니다.
상기 툴을 사용하여 < , >를 <, >로 변환할 수 있고, 반대 방향으로도 변환이 가능합니다.
워드프레스 댓글에서 HTML 태그를 허용하고 싶은 경우 다음과 같은 코드를 차일드 테마의 함수 파일에 추가할 수 있습니다.
/**
* Allows additional HTML tags in WordPress comments.
*
* @param array $allowedtags The array of default allowed tags.
* @return array The modified array of allowed tags.
*/
function custom_allowed_comment_html_tags( $allowedtags ) {
$new_tags = array(
'a' => array(
'href' => true,
'title' => true,
),
'br' => array(),
'em' => array(),
'strong' => array(),
'pre' => array(),
'p' => array(),
'code' => array(),
);
// Merge the two arrays to include the new tags.
return array_merge( $allowedtags, $new_tags );
}
add_filter( 'wp_kses_allowed_html', 'custom_allowed_comment_html_tags', 1, 1 );
이와 같은 코드를 사용하면 <a>, <br>, <em>, <strong>, <pre>, <p>, <code> 태그의 사용이 허용됩니다.