如何删除<pre> tag in output of wordpress shortcode

时间:2019-03-06 11:30:23

标签: wordpress pre

I have a simple plugin for showing list of categories. When display the result, wordpress added it with pre tag automatically. How can I remove it?

I tried using remove_filter('the_content', 'wpautop') but it didnt work.

The parameter $output doesnt include pre tag in result of my Debug (using 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') );

0 个答案:

没有答案