个性化阅读
专注于IT技术分析

在WordPress中使用the_term_list()在列表中显示自定义分类

点击下载

我需要使用the_term_list()在ul中显示我的自定义分类。

我可以让它列出所有我想要的术语,但我需要它们在一个无序的列表中,而不仅仅是由注释分隔的链接列表。

下面是我要做的工作:

<?php echo get_the_term_list($post->ID, 'skills', '<h5>Project Role</h5> ', ', ', '', ); ?>

如果需要的话,这里有WordPress函数参考:http://codex.wordpress.org/Function_Reference/get_the_term_list


#1


这应该得到您的自定义分类显示在无序列表与您的h5标题上的顶部:

<?php echo get_the_term_list( $post->ID, 'skills', '<h5>Project Role</h5><ul><li>', '</li><li>', '</li></ul>' ); ?>

#2


//    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>
赞(0)
未经允许不得转载:srcmini » 在WordPress中使用the_term_list()在列表中显示自定义分类

评论 抢沙发

评论前必须登录!