首页 > 解决方案 > 如何删除

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') );

标签: phphtmlwordpresspre

解决方案


推荐阅读