admin管理员组文章数量:1389768
I would like to apply these two functions that remove <p>
remove_filter('the_content', 'wpautop');
remove_filter( 'the_excerpt', 'wpautop' );
I would like it to only apply to wordpress pages. In the articles I would like to have them. How to do it?
I hope they can help me, I just start programming topics in wordpress.
Thank you.
I would like to apply these two functions that remove <p>
remove_filter('the_content', 'wpautop');
remove_filter( 'the_excerpt', 'wpautop' );
I would like it to only apply to wordpress pages. In the articles I would like to have them. How to do it?
I hope they can help me, I just start programming topics in wordpress.
Thank you.
Share Improve this question asked Oct 4, 2017 at 20:03 JhoedramJhoedram 1011 bronze badge1 Answer
Reset to default 1the_content filter apply to all posts which means pages and articles. What you can do is to add condition to its execution.
First you remove filter as you did
remove_filter('the_content', 'wpautop');
then you add another filter that will call the wpautop function depending on a test like this :
function my_the_content_filter($content) {
if(/* you test if it's an article or whatever you want*/)
$content = wpautop($content);
return $content;
}
add_filter( 'the_content', 'my_the_content_filter' );
like this you may control if the wpautop is called or not depending on your condition.
You do the same for the_excerpt
本文标签: Removefilter (39thecontent3939wpautop39) only pages
版权声明:本文标题:Remove_filter ('the_content', 'wpautop') only pages 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744704204a2620740.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论