2010-09-10 70 views
0

我已经添加了使wpautop过滤器下面我WordPress主题functions.php文件:单只的帖子

//disable wpautop filter 
remove_filter ('the_content', 'wpautop'); 
remove_filter ('the_excerpt', 'wpautop'); 

剥离了周围的一切所有那些讨厌<p> </p>标签WordPress的包裹!

但是,我想知道是否有办法只对非单页(例如:home,archive,category,author等)进行此操作。我想禁用wpautop除了单个帖子和页面...可能吗?

回答

4
function get_rid_of_wpautop(){ 
    if(!is_singular()){ 
    remove_filter ('the_content', 'wpautop'); 
    remove_filter ('the_excerpt', 'wpautop'); 
    } 
} 

add_action('template_redirect', 'get_rid_of_wpautop'); 

添加到您的主题的functions.php文件。