2016-07-27 1 views
0

아래의 기능을 가진 single.php 파일을 특정 페이지 템플리트로 대상화하려고합니다. 페이지 템플리트가 단일 페이지인지 여부에 따라 내용에 wpautop을 발췌하거나 발췌합니다. .php - 작동하지는 않지만 :functions.php가있는 특정 WordPress 페이지 템플리트

모든 도움을 주실 수 있습니다. 나는 질문을하기 전에 포럼에서 이걸 발견 :

Wordpress use functions.php to run function only on specific page template

감사합니다!

/K I이 당신을 위해 무엇을 찾고있는 것 같아요

답변

0

:

remove_filter('the_content', 'wpautop'); 
remove_filter('the_excerpt', 'wpautop'); 

//decide when you want to apply the auto paragraph 

add_filter('the_content', 'my_custom_content'); 
function my_custom_content($content){ 
    if(is_page_template('single.php')){ 
     return $content; //no autop 
    }else{ 
     return wpautop($content); 
    } 
} 

add_filter('the_excerpt', 'my_custom_excerpt'); 
function my_custom_excerpt($content){ 
    if(is_page_template('single.php')){ 
     return $content; //no autop 
    }else{ 
     return wpautop($content); 
    } 
} 
관련 문제