I am using wp_list_categories to display a list of top level terms and their subterms. All the terms are displayed as links.
How could I use wp_list_categories to display terms without being hyperlinked?
I am using wp_list_categories to display a list of top level terms and their subterms. All the terms are displayed as links.
How could I use wp_list_categories to display terms without being hyperlinked?
Hope this simple solution works for you...
<ul>
<?php
foreach (get_categories() as $category){
echo "<li>";
echo $category->name;
echo "</li>";
} ?>
</ul>@egado
Thanks for the suggestion, this works for displaying categories. The problem I have is I am trying to display terms from a custom taxonomy I have set up.
The code I have is as follows
<ul>
<?php wp_list_categories($post->ID, 'taxonomy=MYTAXONOMYNAME&hide_empty=1&title_li='); ?>
</ul>
Using this on single.php this displays the taxonomy terms as hyperlinks. I'd like to display the taxonomy terms without hyperlinks.
Oh ok... maybe this can help: http://codex.wordpress.org/Function_Reference/the_terms
I have used Scribu's tutorial to extend the category walker so do need to use wp_list_categories to display the terms as I want to maintain the "top-level" and "second-level" hierarchy.
Scribu doesn't seem to be available right now so I had to scrap using his tutorial for the time being. I ended up doing it like this:
<ul>
<?php $iterms = wp_get_post_terms($post->ID, "TAXONOMY"); ?>
<?php foreach($iterms as $iterm) : ?>
<?php if($iterm->parent > 0) { ?>
<li class="second-level-item"><?php echo $iterm->name; ?></li>
<?php } else { ?>
<li class="top-level-item"><?php echo $iterm->name; ?></li>
<?php } ?>
<?php endforeach; ?>
</ul>
@egado - thanks for your help
This topic has been closed to new replies.