4

Is there a way to prevent WP from removing br and p tags from posts or pages ?

so far I've added remove_filter('the_content', 'wpautop'); to my functions.php file which completely disables formatting.

However when i edit a post or page, and in the HTML editor add br or p tags then switch back to visual mod the br/p tags that i added get removed.

Is there a way to prevent this ?

4

2 に答える 2

15

これは実際には解決策ではありませんが、回避策です:<p>タグを次のように記述します。

<p dir="ltr">something</p>

このようにして、エディターから切り替えたときにそれらが保持されます。これは、任意のテキスト タグに適用できます。dirここで属性について読むことができます: http://www.w3.org/TR/html401/struct/dirlang.html

タグで同じことをしようとすると、<br>エディターを切り替えたときに WP<br>&nbsp;. これを防ぐために、brタグは次のように記述できます。

<br class="blank" />

また、この問題の決定的な解決策を探していますが、Wordpress 3.6 の新しいリリースでも、まだ何もないようです。誰かがより良い解決策を知っていれば、私はとてもうれしいです!

于 2013-08-09T10:45:42.557 に答える
1

関数.phpで以下のコードを試してください。

function stop_removing_tags(){
    remove_filter('the_content', 'wpautop');
}


add_action('init', 'stop_removing_tags');

コードはテストされていません..。

于 2012-11-11T11:14:24.040 に答える