我想应用这两个函数<p>
remove_filter(\'the_content\', \'wpautop\');
remove_filter( \'the_excerpt\', \'wpautop\' );
我希望它只适用于wordpress页面。在文章中,我希望有他们。怎么做?我希望他们能帮助我,我刚刚开始在wordpress中编程主题。
非常感谢。
我想应用这两个函数<p>
remove_filter(\'the_content\', \'wpautop\');
remove_filter( \'the_excerpt\', \'wpautop\' );
我希望它只适用于wordpress页面。在文章中,我希望有他们。怎么做?我希望他们能帮助我,我刚刚开始在wordpress中编程主题。
非常感谢。
\\u内容过滤器适用于所有帖子,即页面和文章。您可以做的是在其执行中添加条件。
首先,按原样卸下过滤器
remove_filter(\'the_content\', \'wpautop\');
然后添加另一个过滤器,该过滤器将根据以下测试调用wpautop函数: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\' );
这样,您可以根据您的条件控制是否调用wpautop。你也这样做the_excerpt
我有一个自定义端点定义如下: add_action( \'rest_api_init\', function () { register_rest_route( \'menc/v1\', \'/crosscat/(?P<dept>[\\w-]+)/(?P<cat>[\\w-]+)\', array( \'methods\' => \'GET\', \'callback\' =>