Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress使用快捷码禁用自动paragraph_Php_Wordpress - Fatal编程技术网

Php Wordpress使用快捷码禁用自动paragraph

Php Wordpress使用快捷码禁用自动paragraph,php,wordpress,Php,Wordpress,我正在尝试仅在一页上禁用wpautop功能。我试图通过向页面添加一个[wpdisableautop]短代码来实现这一点,但没有成功。短代码没有显示为页面上的原始文本,这意味着Wordpress捕捉到短代码,但它没有做任何事情 到目前为止我所做的: 添加到functions.php: <?php include ( WP_CONTENT_DIR .'/themes/vnc2/disableautop.php'); add_shortcode( 'wpdisableautop', 'disab

我正在尝试仅在一页上禁用wpautop功能。我试图通过向页面添加一个[wpdisableautop]短代码来实现这一点,但没有成功。短代码没有显示为页面上的原始文本,这意味着Wordpress捕捉到短代码,但它没有做任何事情

到目前为止我所做的:

添加到functions.php:

<?php
include ( WP_CONTENT_DIR .'/themes/vnc2/disableautop.php');
add_shortcode( 'wpdisableautop', 'disableautop' );
?>
然后我在/vnc2/dir中创建了一个disableautop.php文件:

<?php
function disableautop () {
remove_filter( 'the_content', 'wpautop' );
}
?>
我不想在functions.php中全局禁用它 我不想使用任何插件
我做错了什么?

包括一个短代码是不起作用的,因为\u内容已经运行了。最好将它添加到functions.php中,并使用wp_head运行它。比如:

function remove_autop() {
    if ( is_page( ID_HERE ) ) {
        remove_filter( 'the_content', 'wpautop' );
    }
}
add_action( 'wp_head', 'remove_autop');