나는 다음과 같은 문제가 : 나는 WP 추가 모든 페이지에 wpautop하지만 내가 필요할 때만 사람을 원하지 않는워드 프레스
를, 그래서이 추가 :
function my_wpautop_correction() {
if(is_page()) {
remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');
}
if(is_page(array(79, 81))) {
add_filter('the_content', 'wpautop');
add_filter('the_excerpt', 'wpautop');
}
}
add_action('pre_get_posts', 'my_wpautop_correction');
을
잘 작동하고있는 것처럼 보이지만 그 기능을 작성하는 가장 좋은 방법인지는 확실하지 않습니다. 나는 이것을 시도했다 :
function my_wpautop_correction() {
if(!(is_page(79) || is_page(81))) {
remove_filter('the_content', 'wpautop');
remove_filter('the_excerpt', 'wpautop');
}
}
add_action('pre_get_posts', 'my_wpautop_correction');
그러나 그것은 나던가 잘못된거야? 난 단지 페이지 79 및 81
당신은 페이지 79, 81을 제거하려는 경우, 당신은 왜 작업 기능에 그들에 add_filter를 호출합니까? – Zzz
죄송합니다. 내 문언이 잘못되었음을 확인했습니다. 79 페이지와 81 페이지에만 wpautop을 추가하고 다른 모든 페이지에서 제거하고 싶습니다. 혼란을 드려 죄송합니다. –
'array()'를 사용하는 것은 개별 페이지를 검사하는 것보다 깔끔하고 [함수] (http://codex.wordpress.org/Function_Reference/is_page)는 배열을 받아 들일 수 있습니다. –