当我在WP中使用文本编辑器时,我有两个选择:
<p>
和<br>
标签,我像网络上的其他数百万人一样为之疯狂……我想像在普通的html页面上一样工作:当我按“ enter”时,它会在我们在屏幕上以及当我们看到它时显示一个空行添加一个代码,它给出了一个行为类似于代码的代码。
现在,例如,如果我在文本中这样做:
"this is a sample sentences <h2>here i want two words with h2 style</h2> here my sentence continues...",
在现实中,它给出这样的结果:
<p>this is a sample sentences <br />
<h2>here i want two words with h2 style</h2><br />
here my sentence continues...</p>
我明白了,我试图通过添加remove_filter ('the_content', 'wpautop');
到功能文件中来删除自动化,但是在这种情况下,在每次换行时我都必须添加一个疯狂的代码。
有解决方案吗?
remove_filter('the_content','wpautop');
//decide when you want to apply the auto paragraph
add_filter('the_content','my_custom_formatting_function');
function my_custom_formatting_function($content){
if(get_post_type()=='YOUR_POSTYPE_NAME') //if it does not work, you may want to pass the current post object to get_post_type
return $content;//no autop
else
return wpautop($content);
}
您能否在中添加上述代码functions.php
?希望对您有帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句