php - 如何删除wordpress 简码输出中的标记
问题描述
我有一个用于显示类别列表的简单插件。显示结果时,wordpress 会自动添加 pre 标签。我怎样才能删除它?
我尝试使用 remove_filter('the_content', 'wpautop') 但它没有用。
参数 $output 在我的调试结果中不包括 pre 标记(使用 Xdebug)。
class ListCategories{
static function list_categories($atts, $content = null) {
$atts = shortcode_atts(
array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( 'Categories' ),
'show_option_none' => __( 'No categories' ),
'number' => null,
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => null
), $atts
);
ob_start();
wp_list_categories($atts);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}
add_shortcode( 'categories', array('ListCategories', 'list_categories') );
解决方案
推荐阅读
- python - 如何通过异常终止cmd /批处理文件来处理python脚本退出
- spring-boot - 将在 karaf 中运行的 osgi 包迁移到 Spring Boot
- python - 使用 nose2 为烧瓶应用程序创建测试
- haskell - 如何在堆栈中创建项目模板?
- c# - .NET Core 3 WPF 检测是否首次运行
- jpa - 无法将父A的实例类型更改为子类B在JPA连接表策略中
- if-statement - 谷歌表格 - 如果工作超过午夜
- amazon-web-services - 在分析通过 Amazon API Gateway 传输的用户请求时更喜欢 AWS XRAY 或 CloudTrail 什么
- java - 使用 GeckoDriver 和 Firefox 通过 Selenium 和 Java 的此会话警告将忽略 Marionette-WARN-TLS 证书错误
- java - 应用程序进入黑屏,然后在线程结束后重新启动