• Resolved Pete

    (@perthmetro)


    I have this code that displays all the custom terms of a specific custom taxonomy(XYZ). Would someone be kind enough to add to this to get it to have an unlinked comma between each term but not after the last term.

    Many thanks, Pete

    <?php $args = array('taxonomy' => 'XYZ'); ?>
    <?php $tax_menu_items = get_categories( $args ); foreach ( $tax_menu_items as $tax_menu_item ):?>
    <a href="<?php echo get_term_link($tax_menu_item,$tax_menu_item->taxonomy); ?>"><?php echo $tax_menu_item->name; ?></a>
    <?php endforeach; ?>
Viewing 5 replies - 16 through 20 (of 20 total)
  • Hmmm… Try:

    <li><strong>Skills: </strong><?php $args = array('taxonomy' => 'skill'); ?>
    $tax_menu_items = get_categories( $args );
    $tax_tot = count( $tax_menu_items ); // count number of items in returned array
    $c = 0; // set up a counter;
    foreach ( $tax_menu_items as $tax_menu_item ):
    $c++; // Increment counter
    <?php echo '<a href="' . get_term_link($tax_menu_item,$tax_menu_item->taxonomy) . '">' . $tax_menu_item->name; . '</a>';
    if ($c < $tax_tot ) echo ', ';
    endforeach; ?></li>

    FYI: Don’t use <b></b> in your HTML. That’s really old, deprecated, markup.

    Thread Starter Pete

    (@perthmetro)

    It blanked out my page… i tried to fix all the php tags but may have missed one or did it wrong? <b> ok

    Thread Starter Pete

    (@perthmetro)

    Umm..
    <li><b>Skills: </b><?php echo get_the_term_list( $post->ID, 'skill', '', ', ', '' ); ?></li>

    What about it?

    Thread Starter Pete

    (@perthmetro)

    This….
    <?php echo get_the_term_list( $post->ID, 'skill', '', ', ', '' ); ?>

    Does exactly the same as what they other piece of code does, with the comma spacing ??

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘Separator for custom terms display’ is closed to new replies.