Wordpress 删除wp_列表_类别列表中的链接

Wordpress 删除wp_列表_类别列表中的链接,wordpress,taxonomy,wp-list-categories,Wordpress,Taxonomy,Wp List Categories,我使用以下代码显示分类法“fachbereiche”的分层列表: $args = array( 'taxonomy' => 'fachbereiche', 'orderby' => 'name', 'title_li' => '', 'feed_type' => '', 'child_of' => 12 ); ?> <ul> <?php wp_list_categories(

我使用以下代码显示分类法“fachbereiche”的分层列表:

$args = array(
  'taxonomy'     => 'fachbereiche',
  'orderby'      => 'name',
  'title_li'     => '',
  'feed_type'       => '',
  'child_of'     => 12
);
?>

<ul>
<?php wp_list_categories( $args ); ?>
</ul>
$args=array(
“分类法”=>fachbereiche,
'orderby'=>'name',
“title_li'=>”,
“提要类型”=>“”,
'child_of'=>12
);
?>
显示的列表几乎不错,唯一的问题是每个分类列表项都包装在一个链接标记中,并链接到分类的单个页面(我没有,也不想要)。如何防止列表被包装在a标签中

你想要的是


您想要的是


虽然上面的答案“sorta”有效,但实际上并不是“删除”链接,而是创建自己的输出

要真正删除链接,可以执行以下操作:

function smyles_strip_a_tags_from_wp_list_categories( $output, $args ) {
    return strip_tags( $output, '<ul><li>' );
}

add_filter( 'wp_list_categories', 'smyles_strip_a_tags_from_wp_list_categories', 9999, 2 );

$args = array(
    'taxonomy'  => 'fachbereiche',
    'orderby'   => 'name',
    'title_li'  => '',
    'feed_type' => '',
    'child_of'  => 12
);
?>

<ul>
    <?php wp_list_categories( $args ); ?>
</ul>

<?php
remove_filter( 'wp_list_categories', 'smyles_strip_a_tags_from_wp_list_categories', 9999 );
函数smyles\u strip\u a\u tags\u from\u wp\u list\u categories($output,$args){
返回条标签($output,
  • ); } 添加过滤器('wp_列表_类别','smyles_条带_标签_自wp_列表_类别',9999,2); $args=数组( “分类法”=>fachbereiche, 'orderby'=>'name', “title_li'=>”, “提要类型”=>“”, 'child_of'=>12 ); ?>
    虽然上面的答案“sorta”有效,但实际上并不是“删除”链接,而是创建自己的输出

    要真正删除链接,可以执行以下操作:

    function smyles_strip_a_tags_from_wp_list_categories( $output, $args ) {
        return strip_tags( $output, '<ul><li>' );
    }
    
    add_filter( 'wp_list_categories', 'smyles_strip_a_tags_from_wp_list_categories', 9999, 2 );
    
    $args = array(
        'taxonomy'  => 'fachbereiche',
        'orderby'   => 'name',
        'title_li'  => '',
        'feed_type' => '',
        'child_of'  => 12
    );
    ?>
    
    <ul>
        <?php wp_list_categories( $args ); ?>
    </ul>
    
    <?php
    remove_filter( 'wp_list_categories', 'smyles_strip_a_tags_from_wp_list_categories', 9999 );
    
    函数smyles\u strip\u a\u tags\u from\u wp\u list\u categories($output,$args){
    返回条标签($output,
    • ); } 添加过滤器('wp_列表_类别','smyles_条带_标签_自wp_列表_类别',9999,2); $args=数组( “分类法”=>fachbereiche, 'orderby'=>'name', “title_li'=>”, “提要类型”=>“”, 'child_of'=>12 ); ?>

      你好,你看到这个了吗?如果需要,请告诉我helped@Kevin.a我经历了很多解决方案,但当我使用get_the_术语时,我在层次结构(列表中的父母和孩子)和wp_list_类别方面遇到了问题,我无法删除链接……您好,您看到了吗?如果需要,请告诉我helped@Kevin.a我已经经历了很多解决方案,但当我使用get_the_术语时,我对层次结构(列表中的父母和孩子)和wp_list_类别有问题,我无法删除链接。。。