Exclude the return links from the wp_list_categories () function;

0

I'm trying to return only the list of taxomanias of a custom post type called "Portfolio". I just need the names of the categories.

The code below is returning the categories with links, does anyone know how to delete those links?

$taxonomy_names = get_object_taxonomies('portfolio');

if(count($taxonomy_names) > 0)
{
     foreach($taxonomy_names as $tax)
     {
         $args = array(
              'orderby' => 'name',
              'hide_empty' => 0,
              'show_count' => 0,
              'pad_counts' => 0,
              'hierarchical' => 1,
              'taxonomy' => $tax,
              'title_li' => ''
            );

        wp_list_categories($args);

     }
}
    
asked by anonymous 11.09.2017 / 05:27

1 answer

0

According to the wp_list_categories documentation in the Wordpress codex, there is no argument to omit the links in the list.

You can manually iterate using the get_terms function:

$taxonomy_names = get_object_taxonomies('portfolio');

if(count($taxonomy_names) > 0) {
    foreach($taxonomy_names as $tax) {
        $terms = get_terms($tax);

        foreach ( $terms as $term ){

            $output  = "";
            $output .= "<li>";
            $output .= $term->name;
            $output .= "</li>";

            echo $output;

        }
    }
}

This should return the result you want.

    
18.09.2017 / 17:57