2014-11-02 151 views
0

我試圖在一個頁面上禁用wpautop功能。我試圖通過在頁面上添加一個[wpdisableautop]簡碼來完成此操作,但它不起作用。簡碼不會在頁面上顯示爲原始文本,這意味着Wordpress會捕獲簡碼,但它不會執行任何操作。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全局禁用它
  • 我不想要使用任何插件

我做了什麼錯了?

回答

0

包含短代碼將不起作用,因爲the_content已經運行。你最好將它添加到你的functions.php並運行它與wp_head。例如:

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