• 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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hope this simple solution works for you…

    <ul>
      <?php
      foreach (get_categories() as $category){
        echo "<li>";
        echo $category->name;
        echo "</li>";
      } ?>
    </ul>
    Thread Starter thirstcard

    (@thirstcard)

    @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.

    Thread Starter thirstcard

    (@thirstcard)

    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.

    Thread Starter thirstcard

    (@thirstcard)

    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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_list_categories to display terms without hyperlinks’ is closed to new replies.