Display custom taxonomy in a list using the_term_list() in WordPress
I need help with displaying my custom taxonomies in a ul using the_term_list().
I can get it to list all the terms I want, but I need them in an unordered list, rather than just a list of links separated by comments.
Here's what I've got to work with:
<?php echo get_the_term_list($post->ID, 'skills', '<h5>Project Role</h5> ', ', ', '', ); ?>
Here's the WordPress function reference, if you 开发者_运维百科need it: http://codex.wordpress.org/Function_Reference/get_the_term_list
This should get your custom taxonomies displaying in an unordered list with your h5 title up top:
<?php echo get_the_term_list( $post->ID, 'skills', '<h5>Project Role</h5><ul><li>', '</li><li>', '</li></ul>' ); ?>
// Use this code
<?php
$taxonomy = 'product-category';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = '';
$empty = 1; // 1 for yes, 0 for no
$args = array(
'taxonomy'=> $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical,
'title_li' => $title, 'hide_empty' => $empty ); ?>
<ul class="sidebar_cat" data-role="listview"> <?php $variable = wp_list_categories( $args ); $variable = str_replace(array('(',')'), '', $variable); $variable = str_replace('(', '<span class="ui-li-count">', $variable);
$variable = str_replace(')', '</span>', $variable); echo $variable; ?>
</ul>
精彩评论