Php 禁用在特定页面模板中自动插入标记

Php 禁用在特定页面模板中自动插入标记,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,将此代码放入function.php remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); 它禁用自动和在页面模板中插入标签 例如,我有3个页面模板,分别是index.php,single.php和taxonomy.php,在我的例子中,所有这些页面模板都删除了自动插入的和,我想要和在taxonomy.php中标记自动。可以吗?您可以使用来检查是否显示分类法存档页面,并且只有在

将此代码放入
function.php

remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );
它禁用自动

在页面
模板中插入标签

例如,我有3个
页面模板
,分别是
index.php
single.php
taxonomy.php
,在我的例子中,所有这些
页面模板
都删除了自动插入的

,我想要

taxonomy.php
中标记
自动
。可以吗?

您可以使用来检查是否显示分类法存档页面,并且只有在该页面未返回
true
时才删除过滤器

if ( ! is_tax() ){
    remove_filter( 'the_content', 'wpautop' );
    remove_filter( 'the_excerpt', 'wpautop' );
}
试试这个

它在特定的
post
服装post类型中禁用自动

function wpc_remove_autop_for_posttype( $content )  
      {  
    // edit the post type here  
    'costume_post_type' === get_post_type() && remove_filter( 'the_content', 'wpautop' );
    return $content;  
   }  
add_filter( 'the_content', 'wpc_remove_autop_for_posttype', 0 );

我想这是更好的方式!感谢您抽出时间回答我的问题。。。但不幸的是,当我将它复制粘贴到我的
函数时,它不起作用。php
这不会在分类页面上处理,但会在其他地方删除过滤器。您希望它只删除分类页面上的过滤器吗?也可以从文档中删除:
is_tax()
在类别存档和标记存档中返回false。检查类别和标记档案时,应分别使用
is_category()
is_tag()
。。。如果可能,如果我在
分类页面模板中
,我希望

是自动的。